Advertisement
savrasov

EuroEnglish

May 2nd, 2017
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. string ans, s, s1; int j = 1;
  2.  
  3. string fir(string s){
  4.     string s1 = "";
  5.     bool r = 0;
  6.     if (s[0] < 'a') s[0] += 32, r = 1;
  7.     for (int i = 0; i < s.size(); i++)
  8.         (s[i] != 'c') ? s1 += s[i] : (i < s.size() - 1) ? (s[i + 1] == 'i' || s[i + 1] == 'e') ? s1 += 's' : (s[i + 1] != 'k') ? s1 += 'k' : s1 += "" : s1 += 'k';
  9.     if (r) s1[0] -= 32;
  10.     return s1;
  11. }
  12.  
  13. bool li(char a) { return (a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z');}
  14.  
  15. string sec(string s){
  16.     string s1 = "";  
  17.     bool r = 0;
  18.     if (s[0] < 'a') s[0] += 32, r = 1;
  19.     s += ' ';
  20.     for (int i = 0; i < s.size() - 1; i++)
  21.         (s[i] == s[i + 1]) ? i++, (s[i] == 'e' || s[i] == 'o') ? (s[i] == 'e') ? s1 += 'i' : s1 += 'u' : s1 += s[i] : s1 += s[i];
  22.     if (r) s1[0] -= 32;
  23.     return s1;
  24. }
  25.  
  26. bool test(string s){ return ((s == "a" || s == "A") || (s == "an" || s == "An") || (s == "the" || s == "The"));}
  27.  
  28. int main()
  29. {
  30.     getline(cin, s); s += '|';
  31.     for (int i = 0; i < s.size(); i++) {
  32.         if (li(s[i])) s1 += s[i];
  33.         else {
  34.             if (test(s1)) s1 = "";
  35.             s1 = fir(s1);
  36.             for (int h = 0; h < 1000; h++) s1 = sec(s1);
  37.             if (s1.size() > 1 && s1[s1.size() - 1] == 'e') s1.resize(s1.size() - 1);
  38.             ans += s1 + s[i];
  39.             s1 = "";
  40.         }
  41.     }
  42.     ans.resize(ans.size() - 1);
  43.     ans = '&' + ans;
  44.     while (ans.size() && ans[ans.size() - 1] == ' ') ans.resize(ans.size() - 1);
  45.     for (; j < ans.size() && ans[j] == ' '; j++);
  46.     if (ans == "&") ans += ' ';
  47.     for (int i = j; i < ans.size(); i++)
  48.         if (!((ans[i] == ' ' && ans[i - 1] == ' '))) cout << ans[i];
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement