ChoDog

Задача P. Древний английский

Nov 27th, 2019
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5.  
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     int n, j = 0;
  11.     string str;
  12.     bool flag;
  13.     cin >> n;
  14.    
  15.     for (int i = 0; i < n; i++) {
  16.         cin >> str;
  17.         str += '%';
  18.         j = 0;
  19.        
  20.         while (j < str.size()) {
  21.             flag = false;
  22.             if ((str[0] == 'e' || str[0] == 'E') && str.size() > 1) {
  23.                 flag = true;
  24.                 if (str[0] == 'e') { str = 'a' + str; str[1] = 'e'; }
  25.                 if (str[0] == 'E') { str = 'A' + str; str[1] = 'e'; }          
  26.                 j += 2;
  27.             }
  28.  
  29.             if (j != 0 && str[j] == 's' && str[j + 1] != 'h') {
  30.                 flag = true;
  31.                 str += '%';
  32.                 int k = str.size() - 2;
  33.                 for (; k >= j; k--) {
  34.                     str[k] = str[k - 1];
  35.                 }
  36.                 str[j] = 't';
  37.                 str[j + 1] = 'h';
  38.                 j += 2;
  39.             }
  40.  
  41.             if (str[j] == 'o' && str[j + 1] == 'o') {
  42.                 flag = true;
  43.                 str[j + 1] = 'u';
  44.                 j += 2;
  45.                 while (str[j] == 'o') j++;
  46.             }
  47.  
  48.             if(!flag)j++;
  49.         }
  50.         for (int cha = 0; cha < str.size() - 1; cha++) {
  51.             cout << str[cha];
  52.         }
  53.         cout << endl;
  54.     }
  55.     return 0;
  56. }
Add Comment
Please, Sign In to add comment