Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2for any given strings. However, it might not be that simple to do it fast.
输入
Each input file contains one test case. Each case consists of two lines which gives S1 and S2, respectively. The string lengths of both strings are no more than 104. It is guaranteed that all the characters are visible ASCII codes and white space, and a new line character signals the end of a string.
输出
For each test case, print S1 - S2 in one line.
思路:这题不难,也是哈希算法,把第二个出现的在ASCII码加一标注,然后找到未标注的输出,ASCII码有127个
#include<cstdio>
#include<cstring>
const int maxn;
int main()
{
char s1[maxn],s2[maxn];
int hashTable[127]={0};
gets(s1);
gets(s2);
for(int i=0;i<strlen(s2);i++)
{
hashTable[s2[i]]++;
}
for(int i=0;i<strlen(s1);i++)
{
if(hashTable[s1[i]]==0);
{
printf("%c",s1[i]);
}
}
return 0;
}