中国黑客业务团队承接一切网站入侵业务,服务器入侵业务,文件加密,文件解密,办公系统入侵,电脑远程控制等业务
联系我们:
技术支持
技术支持








c++ 单词转换 map对象

#include #include #include #include #include #include using namespace std; ifstream& openfile(ifstream &in,const string &filename){ in.close();//close in case it was alrady open in.clear();//clear any existing errors in.open(filename.c_str());//open the file we were given //in要么于指定文件绑定起来了,要么处于错误条件状态 return in;//condition state is good if open succeeded } int main(int argc,char** argv) { map trans_map; string key,value; ifstream map_file; if(!openfile(map_file,transform.txt)){ throw runtime_error(no transformation file); } //read the tansformation map and build the map while(map_file>>key>>value){ trans_map.insert(pair(key,value)); } ifstream input; if(!openfile(input,source.txt)){ throw runtime_error(no input file); } string line;//hold each line from the input //read the text to transform it a line at a time while(getline(input,line)){ istringstream stream(line); //read the line a word at a time string word; //读字符串流 bool lineFirst=true;//controls whether a space is printed while(stream>>word){ //ok:the actual mapwork,this part is the heart of the program map::const_iterator iter=trans_map.find(word); if(iter!=trans_map.end()){ //replace it by the transformation value in the map word=iter->second; } if(lineFirst){ cout<

transform.txt文件内容:


em themcuz becausegratz gratefuli Inah nopos        supposedsez said tanx thankswuz was
source.txt文件内容:

nah i sez tanx cuz i wuz pos tonot cuz i wuz gratz