ZJU-PAT 1050

#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表的哈希去重

發佈了36 篇原創文章 · 獲贊 4 · 訪問量 10萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章