163. [USACO Mat07] Niu Yu, USACO Mat07
☆Input file: latin. in output file: latin. out simple comparison
Time Limit: 1 s memory limit: 128 MB
Translated: zqzas
The cows heard that pig invented a secret language called "pig" because they didn't want FJ to know what they were discussing. the cows also felt so good that they wanted to invent their own language, Niu Yu.
It is easy to convert a Common English word into a normal English word. If a word uses a vowel letter ('A', 'E', 'I', 'O', 'U)Start,Then you only needAdd the end of the word"Cow ".For example, "Udder"Need to be changed"Uddercow ";If the first letter of a word is not a vowel,Put the first letter of the word at the end of the word.,And then add"Ow ".For example"Farmer"Need to be changed"Armerfow ".Therefore, "thecows escape at dawn" will become "hetow owscow escapecow atcowawndow." The cows confidently think that they will not let FJ know their "jailbreak" plan.
It is a pity that none of the cows is a linguistics. They think such a translation is too boring, so this task is handed over to you. you need to translate N (1 ≤ N ≤ 100) English words into niuyu, the word length is between 3 and 40.
Input Format:
- Row 1st: an integer N.
- Row 2nd to row N + 1: Each line contains a word.
Output Format:
- Line 2 to line N, each line has a corresponding niuyu word.
Sample input:
5
Udder
Farmer
Milk
Aaa
Zzz
Sample output:
Uddercow
Armerfow
Ilkmow
Aaaco W
Ideas:
I personally think this is a very simple string processing question. First, I will judge whether the first letter is one of "a, e, I, u, if yes, extract the first one and add it to the end. Finally, add the cow or ow
1 # include <iostream> 2 # include <cstdio> 3 # include <cmath> 4 # include <cstring> 5 # include <algorithm> 6 # include <cstdlib> 7 using namespace std; 8 int n; 9 string a; 10 string B = "cow"; 11 string c = "ow"; 12 int main () 13 {14 freopen ("latin. in "," r ", stdin); 15 freopen (" latin. out "," w ", stdout); 16 scanf (" % d ", & n); 17 for (int I = 1; I <= n; I ++) 18 {19 cin> a; 20 // scanf ("% s", & ); 21 if (a [0] = 'A' | a [0] = 'E' | a [0] = 'I' | a [0] = 'O' | a [0] = 'U ') 22 {23 a = a + B; 24 // printf ("% s \ n", a); 25 cout <a <endl; 26} 27 else 28 {29 int l =. length (); 30 a = a + a [0]; 31 a = a + c; 32 for (int I = 1; I <=. length ()-1; I ++) 33 cout <a [I]; 34 // printf ("% d", a [I]); 35 cout <endl; 36} 37} 38 39 40 41 fclose (stdin); 42 fclose (stdout); 43 return 0; 44}View Code