C ++ не позволяет мне заводить друзей

Это не прямой ответ на ваш вопрос, но мое решение проблемы свинья-латина. Изучая python, я обнаружил, что поиск завершенных примеров очень помог.

word = "snake"

import string

# Create a list of vowels an consonants
vowels   = ['a','e','i','o','u','y']
vowels  += [v.upper() for v in vowels]
consonants = [x for x in string.ascii_letters if x not in vowels]

if word[0] in consonants:
    # Find the first vowel
    idx = min([word.find(v) for v in vowels if word.find(v)>0])

    # Split the word at this point and add 'ay'
    word = word[idx:] + word[:idx] + 'ay'

print(word)
# Returns "akesnay"
30
задан Legion 27 April 2012 в 01:17
поделиться