Advertisement
S_h_u_v_r_o

letter frequency

Nov 4th, 2018
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. //URI Problem 1255(Level Two)
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. int main()
  6. {
  7. int a,b,c,d,e=0,f,g,h,i,z,m;
  8. char j,x[200],w[200],y[200],zz[]={"abcdefghijklmnopqrstuvwxyz"};
  9. scanf("%d",&f);
  10. getchar();
  11. for(a=0; a<f; a++)
  12. {
  13. gets(x);
  14. e=strlen(x);
  15. g=0;
  16. h=0;
  17. z=2;
  18. i=0,m=0;
  19. for(b=0; b<26; b++)
  20. {
  21. for(c=0; c<e; c++)
  22. {
  23. if(x[c] >= 65 && x[c] <= 90){x[c] += 32;}
  24. if(x[c]==zz[b])
  25. {
  26. g++;
  27. }
  28. }
  29. if(g==1)
  30. {
  31. w[h]=zz[b];
  32. h++;
  33. }
  34.  
  35. if(g>z)
  36. {
  37. z=g;
  38. j=zz[b]; //cant build the logic..how I can print this...??
  39. }
  40. if(g==z)
  41. {
  42. //m++;
  43. if(i==0||zz[b]!=y[i]) //cant build the logic..how can I print this...??
  44. y[i]=zz[b];
  45. i++;
  46. }
  47. g=0;//puts(y);
  48. }
  49. w[h]='\0';
  50. y[i]='\0';
  51. if(z==2)
  52. {
  53. puts(w);
  54. }
  55. else if(m<z)
  56. {
  57. printf("%c\n",j);
  58. }
  59. else
  60. {
  61. puts(y);
  62. }
  63.  
  64. }
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement