您的位置:首页 > 其它

ZJU-PAT 1050

2013-03-24 22:04 381 查看
#include<iostream>
#include<string>
using namespace std;

/*
Sample Input:
They are students.
aeiou
Sample Output:
Thy r stdnts.
*/

bool myhash[150];

string s1,s2;

void run()
{
getline(cin,s2);

int i;
string s="";
int len=s1.size();
int len2=s2.size();

for(i=0;i<150;i++) myhash[i]=0;

for(i=0;i<len2;i++)
{
myhash[s2[i]]=1;
}

for(i=0;i<len;i++)
{
if(myhash[s1[i]]==0) s+=s1[i];
}
cout<<s<<endl;
}

int main()
{
while(getline(cin,s1)) run();
return 0;
}

PAT 1050:String Subtraction

利用ascii表的哈希去重
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: