egogoboy

"Диалоги по UCM"

Jun 3rd, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.  
  10.     std::ifstream fin("input.txt");
  11.     std::ofstream fout("output.txt");
  12.  
  13.     vector<char> zn(3);
  14.     zn = { '.', ',', '!', '?'};
  15.  
  16.     vector<string> m;
  17.  
  18.     string s;
  19.  
  20.     string username = " --- skazal ", fedya = " --- skazal Fedya.";
  21.    
  22.     fin >> s;
  23.  
  24.     fin >> s; username += s; string out = s; out += " signed off"; username += '.';
  25.  
  26.     getline(fin, s);
  27.  
  28.     string replik;
  29.  
  30.     fin >> s;
  31.  
  32.     while (getline(fin, s)) {
  33.  
  34.         replik = s.substr(1, s.size() - 1);
  35.  
  36.         bool k = true;
  37.  
  38.         for (int i = 0; i < 4; i++) {
  39.             if (replik[replik.size() - 1] == zn[i]) {
  40.                 k = false;
  41.                 i = 5;
  42.             }
  43.         }
  44.  
  45.         if (k == true) {
  46.             replik += ',';
  47.         }
  48.  
  49.         if (replik[replik.size() - 1] == '.') {
  50.             replik[replik.size() - 1] = ',';
  51.         }
  52.  
  53.         m.push_back(replik);
  54.  
  55.         replik = "";
  56.  
  57.         fin >> s;
  58.  
  59.     }
  60.  
  61.     bool f = true;
  62.  
  63.     for (int i = 0; i < m.size() - 1; i++) {
  64.  
  65.         if (f == true) {
  66.             fout << '"' << m[i] << '"' << fedya << endl;
  67.         }
  68.         else if (f == false) {
  69.             fout << '"' << m[i] << '"' << username << endl;
  70.         }
  71.  
  72.         f = !f;
  73.  
  74.     }
  75.  
  76.     return 0;
  77.  
  78. }
Advertisement
Add Comment
Please, Sign In to add comment