1050. String Subtraction (20)

来源:互联网 发布:网络多媒体箱 编辑:程序博客网 时间:2024/06/05 19:03

用a[300]来存储字符是否再str2中出现过,然后对str1每一个字符进行判断输入就可以了

#include<iostream>#include<string>using namespace std;int a[300] = {0};int main(){    string str1, str2;    getline(cin, str1);    getline(cin, str2);    for (auto x : str2)        a[x] = 1;    for (auto x : str1)        if (a[x] == 0) printf("%c", x);    cout << endl;}
0 0
原创粉丝点击