Broken Keyboard
来源:互联网 发布:用手机写小说的软件 编辑:程序博客网 时间:2024/05/22 10:37
On 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.
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.
输入描述:
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.
输出描述:
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.
输入例子:
7_This_is_a_test_hs_s_a_es
输出例子:
7TI
#include <iostream>#include <string>#include <algorithm> bool charEqualIgnorecase(const char &ch1, const char &ch2);int main(){ std::string firstStr; std::string secondStr; std::cin >> firstStr; std::cin >> secondStr; size_t i = 0; size_t j = 0; std::string outputStr = ""; bool isExists = false; while (i != firstStr.size()) { if (firstStr[i] != secondStr[j]) { for (size_t outI = 0; outI != outputStr.size();outI++) { if (charEqualIgnorecase(outputStr[outI], firstStr[i])) { isExists = true; break; } } if (!isExists) { outputStr += firstStr[i]; } i++; isExists = false; } else { ++i; ++j; } } transform(outputStr.begin(), outputStr.end(), outputStr.begin(), toupper); std::cout << outputStr << std::endl; return 0;} bool charEqualIgnorecase(const char &ch1, const char &ch2){ if (ch1 == ch2) { return true; } else if ((ch1 > 90 ? ch1 - 32 : ch1) == ch2) { return true; } else if ((ch2 > 90 ? ch2 - 32 : ch2) == ch1) { return true; } else return false;}
0 0
- Broken Keyboard
- Broken Keyboard
- Broken Keyboard
- broken keyboard
- swun Broken Keyboard
- UVA11988 Broken Keyboard
- hdu Broken Keyboard(模拟)
- PAT 1084. Broken Keyboard
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- 1084. Broken Keyboard (20)
- Broken Keyboard SDUTOJ
- 1084. Broken Keyboard (20)
- Uva 11988 Broken Keyboard
- 1084.Broken Keyboard
- uva11988 broken keyboard
- UVA11988 Broken Keyboard 链表
- 1084. Broken Keyboard (20)
- sql小结
- QT5串口通信——基础篇
- Unity3D-深入剖析NGUI的游戏UI架构
- ActionBar基本简介
- 在Geogebra中制作生成五角星的宏用于五星红旗
- Broken Keyboard
- 程序员讨厌没有价值的任务
- WEKA使用教程(经典教程转载)
- SSL双向认证以及证书的制作和使用
- List::insert remove
- opencv关于分水岭算法cvWatershed的运用
- WIN8 64位系统 APPIUM环境的安装
- !hdu 4091--贪心、枚举--(思维)
- 第三章第四十二题