1084. Broken Keyboard (20)
来源:互联网 发布:照片打印软件 编辑:程序博客网 时间:2024/04/28 18:48
1084. Broken Keyboard (20)
时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueOn a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.
Now given a string that you are supposed to type, and the string that you actually type out, please list those keys which are for sure worn out.
Input Specification:
Each input file contains one test case. For each case, the 1st line contains the original string, and the 2nd line contains the typed-out string. Each string contains no more than 80 characters which are either English letters [A-Z] (case insensitive), digital numbers [0-9], or "_" (representing the space). It is guaranteed that both strings are non-empty.
Output Specification:
For each test case, print in one line the keys that are worn out, in the order of being detected. The English letters must be capitalized. Each worn out key must be printed once only. It is guaranteed that there is at least one worn out key.
Sample Input:7_This_is_a_test_hs_s_a_esSample Output:7TI在typeOut长度范围内original和打出的typeOut一样两者都加,否则typeOut缺失看看这个缺失的在不再brokenkeys里面,不在加;在typeOut长度范围外 看看剩下的original是否有不在brokenkeys里面的,不在加
评测结果
时间 结果 得分 题目 语言 用时(ms) 内存(kB) 用户 8月01日 14:07答案正确201084C++ (g++ 4.7.2)1436datrilla测试点
测试点 结果 用时(ms) 内存(kB) 得分/满分 0答案正确138412/121答案正确14363/32答案正确13041/13答案正确13041/14答案正确13083/3
#include<iostream> #include<string>using namespace std; bool TheSame(char A, char B){ if (A == B || A >= 'a'&&A <= 'z'&&A - 'a' + 'A' == B) return true; return false;}char AddTheBag(char c){ if (c >= 'a'&&c <= 'z')return c - 'a' + 'A'; return c;}bool NoInbrokeys(string brokenkeys, char ctemp,int lenb){ int index; for (index = 0; index < lenb; index++) { if (brokenkeys[index] == ctemp || ctemp >= 'a'&&ctemp <= 'z'&&ctemp - 'a' + 'A' == brokenkeys[index]) return false; } return true;}int main(){ string original, brokenkeys,typeOut; int oindex, tindex, leno,lent,lenb; cin >> original >> typeOut; leno = original.size(); lent = typeOut.size(); lenb = brokenkeys.size(); for (oindex = 0,tindex=0; oindex < leno; oindex++) { if (tindex < lent) { if (TheSame(original[oindex], typeOut[tindex])) { tindex++; } else if (NoInbrokeys(brokenkeys, original[oindex], lenb)) { brokenkeys += AddTheBag(original[oindex]); lenb++; } } else if (NoInbrokeys(brokenkeys, original[oindex], lenb)) { brokenkeys += AddTheBag(original[oindex]); lenb++; } } cout << brokenkeys << endl; system("pause"); return 0;}
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 浅谈对java中的hashset和Treeset 中重写equals()方法的不同及用法
- mqtt的ClientSub
- JavaScript 如何计算2个时间差 工作时间为8小时
- [python 爬虫学习]利用cookie模拟网站登录
- 图像遍历
- 1084. Broken Keyboard (20)
- 2015C++教学日记
- springMvc上传下载
- grep
- Add Two Numbers
- Paint及Canvas的简单应用
- 多校 hdu 5325
- 运用proguard进行代码混淆
- 巧用Java关键字