1084 Broken Keyboard
题目大意:
给你目标串和实际串,找出破损的键,小写字母输出要变成大写。
解题思路:
首先预处理一下输入的两个字符串,即把小字字母改成大写还有去重,去重我用了ASCLL数组标记,用set的话更方便一点,然后暴力枚举找不同即可。
代码如下:
#include<iostream>
#include<cstdio>
#include<fstream>
#include<set>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<vector>
#include<iomanip>
#include<cstdlib>
#include<list>
#include<queue>
#include<stack>
#include<algorithm>
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define meminf(a) memset(a,inf,sizeof(a))
//vector ::iterator it;
//set<int>::iterator iter;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int main()
{
// std::ios::sync_with_stdio(false);
// cin.tie(0);
// freopen("test.txt","r",stdin);
// freopen("output.txt","w",stdout);
string a,b;
cin>>a>>b;
int book1[200]={0},book2[200]={0};
for(int i=0;i<a.length();i++)//预处理,去重和字母大写
{
if(a[i]>='a'&&a[i]<='z')a[i]=a[i]-'a'+'A';
// int t=int(a[i]);
if(book1[a[i]]!=0)
{
a[i]='#';
}
else book1[a[i]]=1;
}
for(int i=0;i<b.length();i++)
{
if(b[i]>='a'&&b[i]<='z')b[i]=b[i]-'a'+'A';
//int t=int(b[i]);
if(book2[b[i]]!=0)
{
b[i]='#';
}
else book2[b[i]]=1;
}
for(int i=0;i<b.length();i++)//找不同
{
if(b[i]=='#')continue;
for(int j=0;j<a.length();j++)
{
if(a[j]=='#')continue;
else if(a[j]==b[i])
{
a[j]='#';
break;
}
}
}
for(int i=0;i<a.length();i++)
if(a[i]!='#') cout<<a[i];
cout<<endl;
return 0;
}