Advertisement
mstoyanov7

link arrange

Apr 26th, 2022
1,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <vector>
  2. #include <string>
  3. #include <algorithm>
  4. #include <fstream>
  5.  
  6. int main() {
  7.     std::ifstream source;
  8.     source.open("sources.txt", std::ios::in);
  9.     std::vector<std::string> data;
  10.     while (source.good()) {
  11.         std::string link;
  12.         source >> link;
  13.         data.push_back(link);
  14.     }
  15.     source.close();
  16.     std::sort(data.begin(), data.end(), [](std::string& a, std::string& b) {return a < b; });
  17.     std::ofstream outfile;
  18.     outfile.open("output.txt");
  19.     for (auto& link : data) {
  20.         outfile << link << std::endl;
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement