REAL507 删除公共字符
https://www.nowcoder.com/practice/f0db4c36573d459cae44ac90b90c6212?tpId=182&tqId=34789&ru=/exam/oj
简单 通过率:32.96% 时间限制:1秒 空间限制:32M
描述
输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。例如,输入"They are students."和"aeiou",则删除之后的第一个字符串变成"Thy r stdnts."
输入描述:
每个测试输入包含2个字符串
输出描述:
删除后的字符串
示例1
输入:
They are students.
aeiou
输出:Thy r stdnts.
主要思路:哈希表,暴力解法
cpp
#include <iostream>
#include <string>
using namespace std;
int main() {
string s,t;
getline(cin,s);
getline(cin,t);
bool hash[300]={0};
for(char ch:t)
{
hash[ch]=true;
}
for(auto ch:s)
{
if(!hash[ch])
{
cout<<ch;
}
}
return 0;
}