Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(){
  4.  
  5. int n,c[26],i,num,resn,a,max1,max2;
  6. char v[2],resv;
  7.  
  8. while(1){
  9. resn = 0;
  10. max1=0;
  11. max2=0;
  12.  
  13. scanf("%d",&n);
  14. if(n==0)break;
  15.  
  16.  
  17. for(i=0; i<26; i++) c[i] = 0;
  18.  
  19. for(i=0; i<n; i++){
  20.  
  21. scanf("%s", v);
  22. //printf("%d \n",v[0]);
  23. a = v[0];
  24. //printf("%d \n",a);
  25. c[a-65]++;
  26.  
  27.  
  28.  
  29. if(c[a-65]==n/2+1){
  30. resn=i+1;
  31. resv=v[0];
  32. //printf("%c %d\n",v[0],resn);
  33. break;
  34. }
  35.  
  36.  
  37. // if(i==n-1)printf("TIE\n");
  38.  
  39. }
  40.  
  41.  
  42. if(resn == 0){
  43. for(i=0; i<n; i++){
  44. if(max1<c[i]){
  45. max1=c[i];
  46.  
  47. }else if(max2<c[i]){
  48. max2=c[i];
  49. }
  50. if(max1 == max2)printf("TIE\n");
  51. else printf()
  52.  
  53.  
  54. }else printf("%c %d\n",resv,resn);
  55.  
  56.  
  57. }
  58.  
  59. return 0;
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement