[结题报告]12289 - One-Two-Three Time limit: 1.000 seconds


  One-Two-Three 

Your little brother has just learnt to write one, two and three, in English. He has written a lot of those words in a paper, your task is to recognize them. Note that your little brother is only a child, so he may make small mistakes: for each word, there might be at most one wrong letter. The word length is always correct. It is guaranteed that each letter he wrote is in lower-case, and each word he wrote has a unique interpretation.

 

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));
          }
      }

 

posted @ 2013-02-22 16:29  天际。  阅读(241)  评论(0编辑  收藏  举报