Advertisement
cmiN

rmvdup

Apr 30th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <set>
  4. using namespace std;
  5.  
  6.  
  7. typedef set<string> ss_t;
  8. ss_t ipSet;
  9.  
  10.  
  11. void process(char* iname, char* oname)
  12. {
  13.     // NlogN
  14.     ifstream fin(iname);
  15.     string ip;
  16.     while (fin >> ip) ipSet.insert(ip);
  17.     fin.close();
  18.     ofstream fout(oname);
  19.     for (ss_t::iterator it = ipSet.begin(); it != ipSet.end(); ++it) fout << *it << '\n';
  20.     fout.close();
  21. }
  22.  
  23.  
  24. int main(int argc, char* argv[])
  25. {
  26.     if (argc != 3) {
  27.         cout << "Usage: " << argv[0] << " infile outfile" << endl;
  28.     } else {
  29.         process(argv[1], argv[2]);
  30.     }
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement