fork download
  1. /* Read input from STDIN. Print your output to STDOUT*/
  2. #include <math.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <stdlib.h>
  6. #include <assert.h>
  7. #include <limits.h>
  8. #include <stdbool.h>
  9. #include<bits/stdc++.h>
  10. using namespace std;
  11. int main()
  12. {
  13. //Write code here
  14. int g,q,j;
  15. char str[1000];
  16. char s;
  17.  
  18. cin>>q;
  19.  
  20. for(int i=0;i<q;i++)
  21. {
  22.  
  23. int b[200]={0};
  24. cin>>str;
  25. // cout<<str;
  26. int k= strlen(str);
  27. for(int i=0;i<k;i++)
  28. b[str[i]]++;
  29. int m=0;
  30. for( j=96;j<123;j++)
  31. {
  32. if(b[j]>m)
  33. {
  34. m=b[j];
  35. g=j;
  36. }
  37. }
  38. cout<<(char)g<<"\n";
  39.  
  40.  
  41. }
  42. return 0;
  43. }
  44.  
Success #stdin #stdout 0s 4268KB
stdin
3
gqtrawq
fnaxtyyzz
as
stdout
q
y
a