#include
#include
#include
void make_map(ifstream &in,map &dict)
{
string key,word;
while(in>>key>>word,!in.eof()) {
if(in.bad())
throw runtime_error("io data bad\n");
if(in.fail()) {
cout<<"io data fail"<
// err++;
in.clear();
in.sync();
continue;
}
dict[key]=word;
}
}
void trans(ifstream &in,map &dict)
{
// vector vect;
string word;
string line;
while(getline(in,line),!in.eof()) {
if(in.bad())
throw runtime_error("io data bad\n");
if(in.fail()) {
cout<<"io data fail"<
// err++;
in.clear();
in.sync();
continue;
}
istringstream strstream(line);
while( strstream>>word ) {
int count=dict.count(word);
if (!count)
cout<
// vect.push_back(word);
else
// vect.push_back(dict[word]);
cout<
}
cout<
}
// for(vector::iterator iter=vect.begin(); iter!=vect.end(); iter++)
// cout<<*iter<<" ";
}
int main()
{
map dict;
ifstream inmap("map.txt");
ifstream infile("text.txt");
make_map(inmap,dict);
trans(infile,dict);
getchar();
return 0;
}
阅读(248) | 评论(0) | 转发(0) |