fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<ctype.h>
  4.  
  5. int main()
  6. {
  7. char a[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  8. char str[100050], x, y, t;
  9. int i, count, len, max, j;
  10. scanf("%d",&t);
  11. getchar();
  12. while(t--)
  13. {
  14. gets(str);
  15. len=strlen(str);
  16. for(i=0;i<len;i++)
  17. str[i]=tolower(str[i]);
  18. max=0;
  19. for(i=0;i<26;i++)
  20. {
  21. count=0;
  22. for(j=0;j<len;j++)
  23. {
  24. if(str[j]==a[i])
  25. count++;
  26. }
  27. if(count>max)
  28. {
  29. max=count;
  30. x=a[i];
  31. }
  32. else if(count==max)
  33. {
  34. if((int)a[i]>(int)x)
  35. {
  36. x=a[i];
  37. }
  38. else
  39. {
  40. x=x;
  41. }
  42. max=count;
  43. }
  44. }
  45. printf("%c\n",x);
  46. }
  47. return 0;
  48. }
  49.  
Success #stdin #stdout 0s 3120KB
stdin
5
HHaaPPyy!!
abcde
AAbCCdeee
CCCCCCCCCCCCdddseeeeeeeeeeeeeeeee
AGHJI
IIOOO&&&&%%
stdout
y
e
e
e
j