D

Description

你弟弟刚刚学会写英语的一(one)、二(two)和三(three)。他在纸上写了好些一二三,可惜有些字母写错了。已知每个单词最多有一个字母写错了(单词长度肯定不会错),你能认出他写的啥吗? 

Input

第一行为单词的个数(不超过10)。以下每行为一个单词,单词长度正确,且最多有一个字母写错。所有字母都是小写的。

Output

对于每组测试数据,输出一行,即该单词的阿拉伯数字。输入保证只有一种理解方式。

Sample Input

3
owe
too
theee

Sample Output

1
2
3

分析:本题是一个很简单的题,但是一开始看错了题目,理解错了意思,坑了好久。最好的方法就是你只考虑确定为one或two或three的情况,考虑一下字符的长度就更方便了

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 using namespace std;
 5 char s[10];
 6 int main()
 7 {
 8     int n,a;
 9     cin>>n;
10     while(n--)
11     {
12        cin>>s;
13         int m=strlen(s);
14         if(m==3)
15         {
16             if(s[0]=='o'&&s[1]=='n'||s[0]=='o'&&s[2]=='e'||s[1]=='n'&&s[2]=='e') cout<<'1'<<endl;
17              else cout<<'2'<<endl;
18         }
19         else
20         cout<<'3'<<endl;
21     }
22     return 0;
23 }
View Code
原文地址:https://www.cnblogs.com/lbyj/p/5781832.html