PTA 1084 Broken Keyboard (20分)(一个十分简单的练手题)

释放无限光明的是人心,制造无边黑暗的也是人心,光明和黑暗交织着,厮杀着,这就是我们为之眷恋又万般无奈的人世间。

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_es

Sample Output:

7TI
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <ctime>
#include <cctype>
#include <bitset>
#include <utility>
#include <sstream>
#include <complex>
#include <iomanip>
#include<climits>//INT_MAX
#define PP pair<ll,int>
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3fll
#define dinf 1000000000000.0
#define PI 3.1415926
typedef long long ll;
using namespace std;
int const mod=1e9+7;
const int maxn=3e5+10;
string s1,s2;
map<char,int> mp;
int main(){
	getline(cin,s1);
	getline(cin,s2);
	int cd1=s1.size();
	int cd2=s2.size();
	for(int i=0;i<cd1;i++)
		if(s1[i]>='a'&&s1[i]<='z')
			s1[i]=s1[i]+'A'-'a';
	for(int i=0;i<cd2;i++)
		if(s2[i]>='a'&&s2[i]<='z')
			s2[i]=s2[i]+'A'-'a';
	for(int i=0;i<cd2;i++)
		mp[s2[i]]=1;
	for(int i=0;i<cd1;i++)
		if(mp[s1[i]]!=1){
			cout<<s1[i];
			mp[s1[i]]=1;
		}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_44170305/article/details/108414733