o.boj 1081 Bovine Latin
2011-12-17 10:43
183 查看
注:最近这一系列ACM的内容,都是2年多之前的代码,自己回顾一下。
Time Limit: 1000MS Memory Limit: 65536K
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.
* Lines 2..N+1: One word per line.
udder
farmer
milk
aaa
zzz
armerfow
ilkmow
aaacow
zzzow
简单的模拟题
[/code]
Bovine Latin
Submit: 947 Accepted:514Time 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 ownversion, 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 wordsSample Input
5udder
farmer
milk
aaa
zzz
Sample Output
uddercowarmerfow
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; }
[/code]
相关文章推荐
- 最大子矩阵问题hdu 1081
- boj 1336 简单的问题 不过自己没想到 别人解释的~~学习~~
- BOJ 1203 nimm游戏问题 参考别人思路 并且不是非常明白还
- zoj 1081
- HDU 1081 To The Max (DP) 扩展最大子列和,求最大子矩阵和
- o.boj 1031 考古学家SuperRock的新发现
- o.boj 1301 Game
- o.boj 1450 安全锁
- BOJ 262 Channel Coding
- BOJ 385
- HDU 1081 To The Max(最大子矩阵和)
- boj-1002-A-B Problem 大数加减法
- BOJ 652
- hdu 1081 To The Max (动态规划)
- boj 35 Video Surveillance 半平面交求多边形的核
- hdu 1081 To The Max
- URAL 1081
- HDU 1081 To The Max
- OJ_1081 递推数列
- hdu 1081 To The Max