旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及实际被输入的文字,请你列出
肯定坏掉的那些键。
输入描述:
输入在2行中分别给出应该输入的文字、以及实际被输入的文字。每段文字是不超过80个字符的串,由字母A-Z(包括大、小写)、数字0-9、
以及下划线“_”(代表空格)组成。题目保证2个字符串均非空。
输出描述:
按照发现顺序,在一行中输出坏掉的键。其中英文字母只输出大写,每个坏键只输出一次。题目保证至少有1个坏键。
输入例子:
7_This_is_a_test
_hs_s_a_es
输出例子:
7TI
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
int main(void)
{
int count[64] = {};
string put_in;
string put_out;
cin >> put_in >> put_out;
int len1 = put_in.length();
int len2 = put_out.length();
for (int i = 0; i < len2; i++)
{
if (put_out[i] <= '9'&&put_out[i] >= '0')
count[put_out[i] - '0']=1;
else if (put_out[i] <= 'Z'&&put_out[i] >= 'A')
count[put_out[i] - 'A' + 10]=1;
else if (put_out[i] <= 'z'&&put_out[i] >= 'a')
count[put_out[i] - 'a' + 36]=1;
else
count[63]++;
}
for (int i = 0; i < len1; i++)
{
if (put_in[i] <= '9'&&put_in[i] >= '0')
{
if (0 == count[put_in[i] - '0'])
printf("%c", put_in[i]), count[put_in[i] - '0']=2;
}
else if (put_in[i] <= 'Z'&&put_in[i] >= 'A')
{
if(0==count[put_in[i] - 'A' + 10])
printf("%c", put_in[i]), count[put_in[i] - 'A' + 10] = 2, count[put_in[i] - 'A' + 36] = 2;
}
else if (put_in[i] <= 'z'&&put_in[i] >= 'a')
{
if (0 == count[put_in[i] - 'a' + 36])
printf("%c", put_in[i] - 'a' + 'A'), count[put_in[i] - 'a' + 36] = 2, count[put_in[i] - 'a' + 10] = 2;
}
else
if (0 == count[63])
printf("%c", put_in[i]), count[63]=2;
}
return 0;
}