Amonin

Untitled

Dec 13th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <vector>
  5. #include <map>
  6. using namespace std;
  7. void dollar(vector<string>& text) {
  8.     for (string& str : text) {
  9.         str += "$";
  10.     }
  11. }
  12. //void replace_tabs(vector<string>& text) {
  13. //  for (int i = 0; i < text.size(); ++i) {
  14. //      while (text[i].find('\t') != text[i].npos) {
  15. //          text[i].replace(text[i].find('\t'), 1, "^I");
  16. //        }
  17. //    }
  18. //}
  19. void delete_empty(vector<string>& text) {
  20.     for (int i = 0; i < text.size() - 1;) {
  21.         if (text[i] == text[i + 1] && text[i] == "") {
  22.             text.erase(text.begin() + i);
  23.         } else {
  24.             ++i;
  25.         }
  26.     }
  27. }
  28. void numeration(vector<string>& text) {
  29.     for (int i = 0; i < text.size(); ++i) {
  30.         text[i] = to_string(i + 1) + " " + text[i];
  31.     }
  32. }
  33. int main() {
  34.     vector<int> split_req;
  35.     vector<string> text;
  36.     string request;
  37.     getline(cin, request);
  38.     for (int i = 0; i < request.length(); i += 3) {
  39.         if (request[i + 1] == 'E') {
  40.             split_req.push_back(1);
  41.         } else if (request[i + 1] == 's') {
  42.             split_req.push_back(0);
  43.         } else if (request[i + 1] == 'n') {
  44.             split_req.push_back(3);
  45.         } else if (request[i + 1] == 'T') {
  46.             split_req.push_back(2);
  47.         }
  48.     }
  49.     string str;
  50.     while (getline(cin, str)) {
  51.         text.push_back(str);
  52.     }
  53.     sort(split_req.begin(), split_req.end());
  54.     for (int i : split_req) {
  55.         if (i == 0) {
  56.             delete_empty(text);
  57.         } else if (i == 1) {
  58.             dollar(text);
  59.         } else if (i == 2) {
  60.             for (int i = 0; i < text.size(); ++i) {
  61.                 while (text[i].find('\t') != text[i].npos) {
  62.                     text[i].replace(text[i].find('\t'), 1, "^I");
  63.                 }
  64.             }
  65.         } else if (i == 3) {
  66.             numeration(text);
  67.         }
  68.     }
  69.     for (string str : text) {
  70.         cout << str << endl;
  71.     }
  72.     system("pause");
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment