PAT1050 String Subtraction (20 分)

在这里插入图片描述

解析

是集合A中的元素去掉集合B的元素。

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
int main()
{
	string input1, input2;
	getline(cin, input1);
	getline(cin, input2);
	set<char> Show;
	for (auto x : input2)
		Show.insert(x);
	string result;
	for (auto x : input1) {
		if (Show.find(x) == Show.end())
			result += x;
	}
	printf("%s", result.c_str());
}

``

猜你喜欢

转载自blog.csdn.net/weixin_41256413/article/details/84882782