The Seventh Hunan Collegiate Programming Contest 一二三

  • [1103] 一二三

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • 你弟弟刚刚学会写英语的一(one)、二(two)和三(three)。他在纸上写了好些一二三,可惜有些字母写错了。已知每个单词最多有一个字母写错了(单词长度肯定不会错),你能认出他写的啥吗?
  • 输入
  • 第一行为单词的个数(不超过10)。以下每行为一个单词,单词长度正确,且最多有一个字母写错。所有字母都是小写的。
  • 输出
  • 对于每组测试数据,输出一行,即该单词的阿拉伯数字。输入保证只有一种理解方式。
  • 样例输入
  • 3
    owe
    too
    theee
    
  • 样例输出
  • 1
    2
    3
    
  • 提示
  • 来源
  • The Seventh Hunan Collegiate Programming Contest
  • 水题一道,开始直接用的暴力搜索过的,后来改进了一下方法,直接水过

  • #include <cstdio>
    #include <cstring>
    using namespace std;
    int main()
    {
        int t;
        char s[10];
        scanf("%d",&t);
        while(t--)
        {
            scanf("%s",s);
                if(((s[0]>='a'&&s[0]<='z') && s[1]=='n' && s[2]=='e')
                   ||(s[0]=='o' && (s[1]>='a'&&s[1]<='z') && s[2]=='e')
                   ||(s[0]=='o' && s[1]=='n' && (s[2]>='a'&&s[2]<='z')))
                       printf("1\n");
                else if(((s[0]>='a'&&s[0]<='z') && s[1]=='w' && s[2]=='o')
                   ||(s[0]=='t' && (s[1]>='a'&&s[1]<='z') && s[2]=='o')
                   ||(s[0]=='t' && s[1]=='w' && (s[2]>='a'&&s[2]<='z')))
                       printf("2\n");
                else if(((s[0]>='a'&&s[0]<='z') && s[1]=='h' && s[2]=='r' && s[3]=='e' &&s[4]=='e')
                   ||(s[0]=='t' && (s[1]>='a'&&s[1]<='z') && s[2]=='r' && s[3]=='e' &&s[4]=='e')
                   ||(s[0]=='t' && s[1]=='h' && (s[2]>='a'&&s[2]<='z') && s[3]=='e' &&s[4]=='e')
                   ||(s[0]=='t' && s[1]=='h' && s[2]=='r' && (s[3]>='a'&&s[3]<='z') &&s[4]=='e')
                   ||(s[0]=='t' && s[1]=='h' && s[2]=='r' && s[3]=='e' &&(s[4]>='a'&&s[4]<='z')))
                       printf("3\n");
        }
        return 0;
    }
    #include <iostream>
    #include <cstring>
    using namespace std;
    int main()
    {
        int t;
        char s[6];
        cin>>t;
        while(t--)
        {
            cin>>s;
            if(strlen(s)==5)//利用长度的特点
                cout<<"3\n";
            else if(s[2]=='o'&&s[0]!='o')
                cout<<"2\n";
            else if(s[2]!='o'&&s[0]=='t')
                cout<<"2\n";
            else
                cout<<"1\n";
        }
        return 0;
    }



  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值