fork download
  1. #include<stdlib.h>
  2. #include<stdio.h>
  3. #include<math.h>
  4. #include<string.h>
  5. int main()
  6. {
  7.  
  8. int max=0;int p;
  9. int n;int temp;int test;
  10. scanf("%d",&test);
  11. scanf("%d",&n);
  12. int a[n];
  13. for(p=0;p<test;p++)
  14. {
  15. for(int i=0;i<n;i++)
  16. {
  17. scanf("%d",&a[i]);
  18. }
  19. for(int j=0;j<n;j++)
  20. {
  21. int times=0;
  22. for(int k=0;k<n;k++)
  23. {
  24. if(k!=j)
  25. {
  26. if(a[j]==a[k])
  27. {
  28. times=times+1;
  29. }
  30. if(times>max)
  31. {
  32. max=times;
  33. temp=a[j];
  34. }
  35. else if(times==max)
  36. {
  37.  
  38. if(a[j]>temp)
  39. {
  40. continue;
  41. }
  42. else{
  43. temp=a[j];
  44. }
  45. }
  46. }
  47. }
  48. }
  49.  
  50. printf("%d ",temp);
  51. printf("%d ",max+1);
  52. }
  53. return 0;
  54.  
  55. }
  56.  
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
Standard output is empty