1 #include2 #include 3 #include 4 #include 5 using namespace std; 6 7 int main() 8 { 9 set 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 ::iterator it=s.begin(); it!=s.end(); ++it) 20 out < <*it < <"\n"; //按行输出21 22 in.close(); 23 out.close(); 24 25 return 0;26 }