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 } 
**************************************************************
我喜欢程序员,他们单纯、固执、容易体会到成就感;面对困难,能够不休不眠;面对压力,能够迎接挑战。他们也会感到困惑与傍徨,但每个程序员的心中都有一个比尔盖茨或是乔布斯的梦想,用智慧把属于自己的事业开创。其实我是一个程序员
[=.=]
原文地址:https://www.cnblogs.com/kevinGaoblog/p/2598246.html