#C965. Pig Latin Translator
Pig Latin Translator
Pig Latin Translator
You are given a sentence containing a number of words. Your task is to convert each word in the sentence to Pig Latin according to the following rules:
- If a word begins with a vowel (i.e. \(a, e, i, o, u\)), append
way
to the end of the word. - If a word begins with one or more consonants, move them to the end of the word and then append
ay
.
For example, the word "hello" is converted to "ellohay" and "apple" is converted to "appleway". The sentence conversion should preserve the order of words with a single space separating each converted word.
inputFormat
The input is provided on a single line containing a sentence. All words are in lowercase and separated by spaces.
Example: hello world
outputFormat
Output the sentence after converting each word to Pig Latin following the specified rules.
Example: ellohay orldway
hello world
ellohay orldway