原串删除

输入:

They are students

aeiou       //要删去的所有字符

输出:

Thy r stdnts

#include <iostream>    
#include <algorithm>    //S = S1 - S2  散列法简直超绝
#include <cstring>
using namespace std;

const int maxn = 1010;
char a[maxn], b[maxn];

bool hashs[80] ;  //记录字符是否在第二个字符串里出现过

int main() {
	gets_s(a);
	gets_s(b);
	int lenA = strlen(a);
	int lenB = strlen(b);
	for (int i = 0; i < lenB; i++)
	{
		hashs[b[i]] = true;
	}
	for (int i = 0; i < lenA; i++)
	{
		if (hashs[a[i]] == false)
		{
			cout << a[i];
		}
	}
	return 0;
}
 


 

  

 

posted @ 2018-08-05 18:00  道微真理  阅读(95)  评论(0)    收藏  举报