text 文本去重行

 1 #include <iostream> 
 2 #include <set> 
 3 #include <fstream> 
 4 #include <string> 
 5 using namespace std; 
 6 
 7 int main() 
 8 { 
 9     set <string> s; 
10     string str; 
11     ifstream in("source.txt");     
12     ofstream out("result.txt"); 
13 
14     while(getline(fin,str))   //按行读取
15     { 
16         s.insert(str); 
17     } 
18 
19     for(set<string>::iterator it=s.begin(); it!=s.end(); ++it) 
20         out < <*it < <"\n";   //按行输出
21 
22     in.close(); 
23     out.close(); 
24 
25     return 0;
26 } 

posted on 2012-07-18 22:09  NLP新手  阅读(580)  评论(0编辑  收藏  举报

导航