一二三

切切水题抚慰受伤的心=~=


1250: 一二三

Time Limit: 1 Sec   Memory Limit: 128 MB
[ Submit][ Status][ Web Board]

Problem Description

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

Input

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

Output

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

Sample Input

3
owe
too
theee

Sample Output

1
2
3

HINT

Source

Difficulty

Author

admin

这个很好弄的,首先根据字符串长度判断 three ,然后根据匹配度判断 one 和 two

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#define PI acos(-1.0)
#define eps 1e-8
#define LL long long
#define moo 31536000
#define INF 1e9
#define maxn 100010
using namespace std;
char s[100];
char one[4]="one",two[4]="two";
int ans1,ans2;
int main()
{
    int n;
    while(~scanf("%d",&n) && n)
    {
     ans1=ans2=0;
     scanf("%s",s);
        int len=strlen(s);
        if(len==5)
                printf("3\n");
        else
        {
            for(int i=0;i<=2;i++)
            {
                if(s[i]==one[i])
                    ans1++;
                if(s[i]==two[i])
                    ans2++;
            }
            if(ans1>ans2)
                printf("1\n");
            else
                printf("2\n");
        }
    }
    return 0;
}
 
/**************************************************************
    Problem: 1250
    User: mangogo
    Language: C++
    Result: Accepted
    Time:0 ms
    Memory:1436 kb
****************************************************************/


转载于:https://www.cnblogs.com/zhanpang/p/5682885.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值