[结题报告]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));
          }
      }

 

转载于:https://www.cnblogs.com/sjy123/archive/2013/02/22/2922488.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值