[结题报告]12289 - One-Two-Three Time limit: 1.000 seconds
2013-02-22 16:29
423 查看
One-Two-Three |
Input
The first line contains the number of words that your little brother has written. Each of the following lines contains a single word with all letters in lower-case. The words satisfy the constraints above: at most one letter might be wrong, but the word length is always correct. There will be at most 10 words in the input.Output
For each test case, print the numerical value of the word.Sample Input
3 owe too theee
Sample Output
1 2 3 参考代码: 根据题给信息,这个小朋友写出的单词长度保证,而且保证只错一个字母,所以我首先判断单词长度,3是5个字母,所以比较字母长度即可,two,one选择其中一个用if语句判断一下就好。我选用的是2,具体判断看下面代码.
#include"stdio.h" #include"string.h" int fun(char *s) { int len = strlen(s); if (len == 5) return 3; else if ((s[0]=='t' && s[1]=='w') || (s[0]=='t' && s[2]=='o') || (s[1]=='w' && s[2]=='o')) return 2; return 1; } main() { int n,m; char a[10]; scanf("%d ",&n); while(n--) {gets(a); printf("%d\n",fun(a)); } }
相关文章推荐
- [结题报告]11494 - Queen Time limit: 1.000 seconds
- [解题报告]12289 - One-Two-Three
- [结题报告]11364 - Parking Time limit: 1.000 seconds
- 12289 - One-Two-Three
- [结题报告]458 - The Decoder Time limit: 3.000 seconds
- UVa 12289 One-Two-Three (water ver.)
- UVA 12289 One-Two-Three
- 12289 - One-Two-Three
- UVA OJ 12289 One-Two-Three
- [结题报告]10235 - Simply Emirp Time limit: 3.000 seconds
- UVa 12289 - One-Two-Three
- UVa 12289 - One-Two-Three
- [结题报告]100 - The 3n + 1 problem Time limit: 3.000 seconds
- [结题报告]10055 - Hashmat the Brave Warrior Time limit: 3.000 seconds
- [结题报告]10082 - WERTYU Time limit: 3.000 seconds
- [结题报告]10340 - All in All Time limit: 3.000 seconds
- ChargeSystem——One,Two,Three
- 奥运英语[9]数字:1,2,3……10 Numbers: one, two, three...ten.
- Uva 12889 One-Two-Three
- one two three zero six