1084. Broken Keyboard (20)
来源:互联网 发布:知乎周刊是什么 编辑:程序博客网 时间:2024/05/18 12:03
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.
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
#include<stdio.h> #include<iostream> #include<string> #include<vector> #include<algorithm> #include<string.h> using namespace std; int main(){ freopen("F://Temp/input.txt", "r", stdin); string str_in, str_out; cin >> str_in >> str_out; transform(str_in.begin(), str_in.end(), str_in.begin(), ::toupper);//先处理为都是大写的情况 transform(str_out.begin(), str_out.end(), str_out.begin(), ::toupper); string str_in_2, str_out_2; for (int i = 0; i < str_in.size(); ++i){ if (str_in_2.find(str_in[i]) == string::npos){ str_in_2 += str_in[i]; } } for (int i = 0; i < str_out.size(); ++i){ if (str_out_2.find(str_out[i]) == string::npos){ str_out_2 += str_out[i]; } } for (int i = 0; i < str_in_2.size(); ++i){ if (str_out_2.find(str_in_2[i]) == string::npos){//输出中没有输出的这个字符,那么就是坏键盘,输出 cout << str_in_2[i]; } } cout << endl; 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)
- 简单二维数组转置问题
- C++ nontrival class 值传递的机制。
- wifi direct/p2p流程分析 基于android 5.1
- Eclipse+pydev插件-----python开发环境
- 自定义ViewPagerIndicator(下)
- 1084. Broken Keyboard (20)
- 创建java线程方式之三实现Callable接口
- PHP实现留言本代码
- 差分约束系统
- hdu5011Game nim博弈
- Struts2数据的封装
- 32位Ubuntu安装VSCode
- ListView中getChildAt(index)的使用注意事项
- 输入三个数字使用指针进行排序(冒泡原理)