注:最近这一系列ACM的内容,都是2年多之前的代码,自己回顾一下。
Bovine Latin
Submit: 947 Accepted:514
Time Limit: 1000MS Memory Limit: 65536K
Description
The cows have heard that the pigs use a secret language called "Pig Latin" when they want to communicate with each other without Farmer John being able to understand what they are saying. Thinking this is an excellent idea, they have invented their own
version, aptly called Bovine Latin.
Converting an English word to a Bovine Latin word is quite simple. For words that start with a vowel ('a', 'e', 'i', 'o' or 'u'), "cow" is added to the end of the word; for example, "udder" becomes "uddercow". For words that do not begin with a vowel,
the first letter is moved to the end of the word, and "ow" is added; e.g., "farmer" becomes "armerfow". So "the cows escape at dawn" becomes "hetow owscow escapecow atcow awndow." The cows fervently believe that FJ will not understand this subterfuge.
Never known as enthusiastic linguists, the cows find this translation quite tedious and thus have asked you to write a program that will take single words and translate them into Bovine Latin. They will provide you with N (1 <= N <= 100) words to translate;
word lengths range from 3 to 40 letters.
Input
* Line 1: A single integer: N
* Lines 2..N+1: One word per line.
Output
* Lines 1..N: The Bovine Latin translations of the given words
Sample Input
5
udder
farmer
milk
aaa
zzz
Sample Output
uddercow
armerfow
ilkmow
aaacow
zzzow
Source
USACO MAR07 BRONZE Division
简单的模拟题
#include <iostream>
#include <string>
using namespace std;
int main()
{
string S[105];
int N;
char ch;
cin >> N;
for (int i = 0; i < N; i++)
cin >> S[i];
for (int i = 0; i < N; i++)
{
if (S[i][0] == 'a' || S[i][0] == 'e' || S[i][0] == 'i' ||
S[i][0] == 'o' || S[i][0] == 'u' )
cout << S[i] << "cow" << endl;
else
{
ch = S[i][0];
S[i].replace(0, 1, "");
S[i].insert(S[i].end(), ch);
cout << S[i] << "ow" << endl;
}
}
// system("pause");
return 0;
}