标签:namespace 一段 下划线 test tps 键盘 输入 main https
旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出肯定坏掉的那些键。
输入在 2 行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过 80 个字符的串,由字母 A-Z(包括大、小写)、数字 0-9、以及下划线 _
(代表空格)组成。题目保证 2 个字符串均非空。
按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有 1 个坏键。
7_This_is_a_test
_hs_s_a_es
7TI
#include<bits/stdc++.h>
using namespace std;
int main()
{
string right, wrong;
cin >> right;
cin >> wrong;
string ans = "";
for(int i=0;i<right.size();i++)
{
bool f = true;
for(int j=0;j<wrong.size();j++)
if(right[i] == wrong[j])
f = false;
if(f) //说明没找到
{
char ch = toupper(right[i]);
bool exist = false;
for(int k=0;k<ans.size();k++)
if(ch == ans[k])
exist = true;
if(!exist)
ans += ch;
}
}
cout << ans;
return 0;
}
https://pintia.cn/problem-sets/994805260223102976/problems/994805292322111488
标签:namespace 一段 下划线 test tps 键盘 输入 main https
原文地址:https://www.cnblogs.com/MartinLwx/p/11614144.html