一般字符串问题:一二三

描述
你弟弟刚刚学会写英语的一(one)、二(two)和三(three)。他在纸上写了好些一二三,可惜有些字母写错了。
已知每个单词最多有一个字母写错了(单词长度肯定不会错),你能认出他写的啥吗?
输入
第一行为单词的个数(不超过 10)。以下每行为一个单词,单词长度正确,且最多有一个字母写错。所有字母都是小写的。
输出
对于每组测试数据,输出一行,即该单词的阿拉伯数字。输入保证只有一种理解方式。
样例输入

owe 
too 
theee
样例输出


3
#include<stdio.h>
#include <string.h>
int main()
{
	char str[10];
	int N,n,i,l;
	scanf("%d",&N);
	while(N--)
	{
		scanf("%s",&str);
        l=strlen(str);
		if(l==3)
		{
		if((str[0]=='o'&&str[1]=='n')||(str[0]=='o'&&str[2]=='e')||(str[1]=='n'&&str[2]=='e'))
		{
			printf("1\n");
		}
		else 
		{
			printf("2\n");
		}
		}
		else
		{
			printf("3\n");
		}
	}
	return 0;
}


猜你喜欢

转载自blog.csdn.net/xiaoli130134/article/details/80489901