PAT 1050. String Subtraction

题目:http://pat.zju.edu.cn/contests/pat-a-practise/1050

题解:

代码:

#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<set>
#include<vector>
#include<algorithm>
using namespace std;
#define MAX 10005
set<char> setx;
char a[MAX],b[MAX];
int main()
{
    bool flag=true;
    gets(a);
    gets(b);
    int lenA=strlen(a);
    int lenB=strlen(b);
    for(int i=0; i<lenB; ++i)
        setx.insert(b[i]);
    for(int i=0; i<lenA; ++i)
    {
        flag=true;
        if(setx.count(a[i])>0)
            flag=false;
        if(flag)
            printf("%c",a[i]);
    }
    printf("\n");
    return 0;
}

来源: http://blog.csdn.net/acm_ted/article/details/20150001

你可能感兴趣的:(PAT 1050. String Subtraction)