STANAANDREY

hackathon: "vocale"

Jan 24th, 2022 (edited)
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const string pairs = "ae ai ao au ea ee ei eo eu ia ie ii io iu oa oe oi ou ua oo ue ui uu uo";
  4. map<string, int> fr;
  5.  
  6. bool isVowel(char c) {
  7.     return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
  8. }
  9.  
  10. signed main() {
  11.     //freopen("text.in", "r", stdin);
  12.     string text;
  13.     for (string line; getline(cin, line);) {
  14.         text += line + '\n';
  15.     }
  16.  
  17.     if (!text.size()) {
  18.         puts(pairs.c_str());
  19.         return 0;
  20.     }
  21.  
  22.     for (size_t i = 1; i < text.size(); i++) {
  23.         if (isVowel(text[i - 1]) && isVowel(text[i])) {
  24.             string pairOfVowels = string(1, text[i - 1]) + string(1, text[i]);
  25.             fr[pairOfVowels]++;
  26.         }
  27.     }
  28.  
  29.     int frMax = -1;
  30.     for (const auto &it : fr) {
  31.         frMax = max(frMax, it.second);
  32.     }
  33.  
  34.     for (const auto &[fi, se] : fr) {
  35.         if (se == frMax) {
  36.             cout << fi << ' ';
  37.         }
  38.     }
  39.  
  40.     return 0;
  41. }
  42.  
Add Comment
Please, Sign In to add comment