Problem: 492 Pig-Latin
You have decided that PGP encryptation is not strong enough for your email. You have decided to supplement it by first converting your clear text letter into Pig Latin before encrypting it with PGP.
Input and Output
You are to write a program that will take in an arbitrary number of lines of text and output it in Pig Latin. Each line of text will contain one or more words. A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case). Words should be converted to Pig Latin according to the following rules (non-words should be output exactly as they appear in the input):
1. Words that begin with a vowel (a, e, i, o, or u, and the capital versions of these) should just have the string ``ay'' (not including the quotes) appended to it. For example, ``apple'' becomes ``appleay''.
2. Words that begin with a consonant (any letter than is not A, a, E, e, I, i, O, o, U or u) should have the first consonant removed and appended to the end of the word, and then appending ``ay'' as well. For example, ``hello'' becomes ``ellohay''.
3. Do not change the case of any letter.
Sample Input
This is the input.
Sample Output
hisTay isay hetay inputay.
Description of the Solution:
You got Run time error
if u use gets () function or scanf () or any other function to store the whole input at once and after that try to process it, u will get the same reply from robot judge: RTE !!!
perhaps, the reason is, the input text is too big to store in any an array we plan/guess to declare, whether it is 1 million or 10 million elements !! so, get the input as character by character.
let, character variable Ch continue (Ch = getcharacter ()) // in C/C++ it would be getchar () function if (Ch is equals to EOF) then, return otherwise, check its vowel or not follow the procedure // remember one thing, the input text may not consist with only alphabet. So, in every step check whether it’s alphabet or not
// another thing, “A word is defined as a consecutive sequence of letters”
Code In C/C++:
You have decided that PGP encryptation is not strong enough for your email. You have decided to supplement it by first converting your clear text letter into Pig Latin before encrypting it with PGP.
Input and Output
You are to write a program that will take in an arbitrary number of lines of text and output it in Pig Latin. Each line of text will contain one or more words. A ``word'' is defined as a consecutive sequence of letters (upper and/or lower case). Words should be converted to Pig Latin according to the following rules (non-words should be output exactly as they appear in the input):
1. Words that begin with a vowel (a, e, i, o, or u, and the capital versions of these) should just have the string ``ay'' (not including the quotes) appended to it. For example, ``apple'' becomes ``appleay''.
2. Words that begin with a consonant (any letter than is not A, a, E, e, I, i, O, o, U or u) should have the first consonant removed and appended to the end of the word, and then appending ``ay'' as well. For example, ``hello'' becomes ``ellohay''.
3. Do not change the case of any letter.
Sample Input
This is the input.
Sample Output
hisTay isay hetay inputay.
Description of the Solution:
You got Run time error
if u use gets () function or scanf () or any other function to store the whole input at once and after that try to process it, u will get the same reply from robot judge: RTE !!!
perhaps, the reason is, the input text is too big to store in any an array we plan/guess to declare, whether it is 1 million or 10 million elements !! so, get the input as character by character.
let, character variable Ch continue (Ch = getcharacter ()) // in C/C++ it would be getchar () function if (Ch is equals to EOF) then, return otherwise, check its vowel or not follow the procedure // remember one thing, the input text may not consist with only alphabet. So, in every step check whether it’s alphabet or not
// another thing, “A word is defined as a consecutive sequence of letters”
Code In C/C++:
No comments:
Post a Comment