1011: 一二三
题目描述
你弟弟刚刚学会写英语的一(one)、二(two)和三(three)。他在纸上写了好些一二三,可惜有些字母写错 了。已知每个单词最多有一个字母写错了(单词长度肯定不会错),你能认出他写的啥吗?
输入
第一行为单词的个数(不超过 10)。以下每行为一个单词,单词长度正确,且最多有一个字母写错。所有 字母都是小写的。
输出
对于每组测试数据,输出一行,即该单词的阿拉伯数字。输入保证只有一种理解方式。
样例输入 Copy
3
owe
too
theee
样例输出 Copy
1
2
3
#include<iostream>
#include<string.h>
using namespace std;
int main(){
int num,str[3];
cin>>num;
for(int i=0;i<num;i++)
{
string ch;
cin>>ch;
if(ch.size()==5) cout<<"3"<<endl;
else if((ch[0]=='o'&&ch[1]=='n')||(ch[0]=='o'&&ch[2]=='e')||(ch[1]=='n'&&ch[2]=='e'))
cout<<"1"<<endl;
else cout<<"2"<<endl;
}
return 0;
}
//第二种方法(两种思想差不多):
#include<iostream>
#include<string.h>
using namespace std;
int main(){
int num,str[3];
cin>>num;
for(int i=0;i<num;i++)
{
int t=0;
string ch,ch1="one";
cin>>ch;
if(ch.size()==5) cout<<"3"<<endl;
else
{
for(int j=0;j<3;j++)
if(ch1[j]==ch[j]) t++;
if(t>=2) cout<<"1"<<endl;
else cout<<"2"<<endl;
}
}
return 0;
}