Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int freq[30];
  6.  
  7. void addChar(char c) {
  8.     if ('A' <= c && c <= 'Z') c += 'a' - 'A';
  9.     if ('a' <= c && c <= 'z') freq[c - 'a']++;
  10. }
  11.  
  12. int main() {
  13.     // freopen("in", "r", stdin);
  14.     // freopen("out", "w", stdout);
  15.  
  16.     int t;
  17.     scanf("%d ", &t);
  18.  
  19.     while (t--) {
  20.         char s[210];
  21.         fgets(s, 210, stdin);
  22.  
  23.         memset(freq, 0, sizeof freq);
  24.         for (int i = 0; s[i]; i++) addChar(s[i]);
  25.  
  26.         int maxi = *max_element(freq, freq + 30);
  27.         for (int i = 0; i < 26; i++) {
  28.             if (freq[i] == maxi) printf("%c", 'a' + i);
  29.         }
  30.         printf("\n");
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement