Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <string>
- #include <vector>
- #include <map>
- using namespace std;
- void dollar(vector<string>& text) {
- for (string& str : text) {
- str += "$";
- }
- }
- //void replace_tabs(vector<string>& text) {
- // for (int i = 0; i < text.size(); ++i) {
- // while (text[i].find('\t') != text[i].npos) {
- // text[i].replace(text[i].find('\t'), 1, "^I");
- // }
- // }
- //}
- void delete_empty(vector<string>& text) {
- for (int i = 0; i < text.size() - 1;) {
- if (text[i] == text[i + 1] && text[i] == "") {
- text.erase(text.begin() + i);
- } else {
- ++i;
- }
- }
- }
- void numeration(vector<string>& text) {
- for (int i = 0; i < text.size(); ++i) {
- text[i] = to_string(i + 1) + " " + text[i];
- }
- }
- int main() {
- vector<int> split_req;
- vector<string> text;
- string request;
- getline(cin, request);
- for (int i = 0; i < request.length(); i += 3) {
- if (request[i + 1] == 'E') {
- split_req.push_back(1);
- } else if (request[i + 1] == 's') {
- split_req.push_back(0);
- } else if (request[i + 1] == 'n') {
- split_req.push_back(3);
- } else if (request[i + 1] == 'T') {
- split_req.push_back(2);
- }
- }
- string str;
- while (getline(cin, str)) {
- text.push_back(str);
- }
- sort(split_req.begin(), split_req.end());
- for (int i : split_req) {
- if (i == 0) {
- delete_empty(text);
- } else if (i == 1) {
- dollar(text);
- } else if (i == 2) {
- for (int i = 0; i < text.size(); ++i) {
- while (text[i].find('\t') != text[i].npos) {
- text[i].replace(text[i].find('\t'), 1, "^I");
- }
- }
- } else if (i == 3) {
- numeration(text);
- }
- }
- for (string str : text) {
- cout << str << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment