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. while(t--)
  12. {
  13. gets(str);
  14. len=strlen(str);
  15. for(i=0;i<len;i++)
  16. str[i]=tolower(str[i]);
  17.  
  18. printf("%s",str);
  19.  
  20. max=0;
  21. for(i=0;i<26;i++)
  22. {
  23. count=0;
  24. for(j=0;j<len;j++)
  25. {
  26. if(str[j]==a[i])
  27. count++;
  28. }
  29. if(count>max)
  30. {
  31. max=count;
  32. x=a[i];
  33. }
  34. else if(count==max)
  35. {
  36. if((int)a[i]>(int)x)
  37. {
  38. x=a[i];
  39. }
  40. else
  41. {
  42. x=x;
  43. }
  44. max=count;
  45. }
  46. }
  47. printf("%c\n",x);
  48. }
  49. return 0;
  50. }
  51.  
Success #stdin #stdout 0s 2056KB
stdin
2
hhhhaaaa aaa
HHHH AAAAA
stdout
hhhhaaaa aaah
hhhh aaaaah