一二三(The Seventh Hunan Collegiate Programming Contest)
一二三
你弟弟刚刚学会写英语的一(one)、二(two)和三(three)。他在纸上写了好些一二三,可惜有些字母写错了。已知每个单词最多有一个字母写错了(单词长度肯定不会错),你能认出他写的啥吗?
输入
第一行为单词的个数(不超过10)。以下每行为一个单词,单词长度正确,且最多有一个字母写错。所有字母都是小写的。
输出
对于每组测试数据,输出一行,即该单词的阿拉伯数字。输入保证只有一种理解方式。
样例输入
3
owe
too
theee
样例输出
1
2
3
分析:此题就是一一对比字符串的符合,因为只有三种情况,前两种都是三位,所以一起比较,最后一个单独比较,直接比较,计一个临时变量就可
代码:
#include<iostream>
#include<string.h>
using namespace std;
int main(){
char s[10];
string s1="one";
string s2="two";
string s3="three";
int T;
int i,j;
cin>>T;
while(T--){
int len;
int temp1=0,temp2=0,temp3=0;
cin>>s;
len=strlen(s);
if(len==3){
for(i=0;i<3;i++){
if(s[i]==s1[i]){temp1++;}
if(s[i]==s2[i]){temp2++;}
}
if(temp1>=2){cout<<"1"<<endl;}
if(temp2>=2){cout<<"2"<<endl;}
}
if(len==5){
for(j=0;j<5;j++){
if(s[j]==s3[j]){temp3++;}
}
if(temp3>=4){cout<<"3"<<endl;}
}
}
return 0;
}
一二三(The Seventh Hunan Collegiate Programming Contest)的更多相关文章
- 盒子游戏(The Seventh Hunan Collegiate Programming Contest)
盒子游戏 有两个相同的盒子,其中一个装了n个球,另一个装了一个球.Alice和Bob发明了一个游戏,规则如下:Alice和Bob轮流操作,Alice先操作.每次操作时,游戏者先看看哪个盒子里的球的数目 ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem A
Problem A Almost Palindrome Given a line of text, find the longest almost-palindrome substring. A st ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem F
Problem F Funny Car Racing There is a funny car racing in a city with n junctions and m directed roa ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem H
Problem H High bridge, low bridge Q: There are one high bridge and one low bridge across the river. ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem I
Problem I Interesting Calculator There is an interesting calculator. It has 3 rows of button. Row 1: ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem J
Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem G
Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem L
Problem L Last Blood In many programming contests, special prizes are given to teams who solved a pa ...
- The Ninth Hunan Collegiate Programming Contest (2013) Problem C
Problem C Character Recognition? Write a program that recognizes characters. Don't worry, because yo ...
随机推荐
- 1030 - Image Is Everything
Your new company is building a robot that can hold small lightweight objects. The robot will have th ...
- overflow:hidden与position:absolute
在做一个下拉框的动画效果中遇到了这个bug,记录一下. 在写下拉框的动画的时候,一般我们的做法都是把下拉框的外盒子设为overflow:hidden,然后设下外层盒子高度,之后通过js慢慢的改变高度从 ...
- QDockWidget嵌套布局详解-实现Visual Studio布局
概述 许多工程软件,如Qt Creator,VS,matlab等,都是使用dock布局窗口,这样用户可以自定义界面,自由组合窗口. Qt的嵌套布局由QDockWidget完成,用Qt Creator拖 ...
- 用Delphi进行word开发
使用以CreateOleObjects方式调用Word 实际上还是Ole,但是这种方式能够真正做到完全控制Word文件,能够使用Word的所有属性,包括自己编写的VBA宏代码.------------ ...
- VC socket Connect 超时时间设置
设置connect超时很简单,CSDN上也有人提到过使用select,但却没有一个令人满意与完整的答案.偶所讲的也正是select函数,此函数集成在winsock1.1中,简单点讲,"作用使 ...
- android优化原理
时间换时间: 数据的异步载入 分批载入. 开机加速. 时间换空间: 分页. 空间换时间: everything.exe 音乐 图库 在开机启动后, sd卡被挂载 生成数据库. 空间换空间: 8G内存 ...
- (android高仿系列)今日头条 --新闻阅读器 (三) 完结 、总结 篇
从写第一篇今日头条高仿系列开始,到现在已经过去了1个多月了,其实大体都做好了,就是迟迟没有放出来,因为我觉得,做这个东西也是有个过程的,我想把这个模仿中一步一步学习的过程,按照自己的思路写下来,在根据 ...
- 从注册流程 分析如何安全退出多个Activity 多种方式(附DEMO)
前言 由于一个同学问到我如何按照一个流程走好之后回到首页,我以前看到过4个解决方案,后来发现有做个记录和总结的必要,就写了这篇博文.(之前看小强也写过一篇,这里通过自身的分析完整的总结一下以下6种 ...
- 可以根据柜子内表取出所有的柜子信息的BAPI函数
DATA: gt_hunumbers TYPE STANDARD TABLE OF bapihunumber, gt_huitem TYPE STANDARD TABLE OF bapih ...
- 暂停和屏蔽右键网页中的Flash
如何暂停网页中的Flash?原理很简单,就是屏蔽Flash的消息即可.屏蔽右键也可以通过此方法 直接贴代码吧,加了注释,很容易就能懂了 新建工程,加一个WebBrowser,再加两个按钮.Flash ...