fork download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int n,maxValue = 0, maxCount = 0, i, j;
  5. int a[10];
  6. scanf("%d",&n);
  7. for(i=0;i<n;i++)
  8. {scanf("%d",&a[i]);}
  9. for (i = 0; i < n; ++i)
  10. {
  11. int count = 0;
  12.  
  13. for (j = 0; j < n; ++j)
  14. {
  15. if (a[j] == a[i])
  16. ++count;
  17. }
  18.  
  19. if (count > maxCount)
  20. {
  21. maxCount = count;
  22. maxValue = a[i];
  23. }
  24. }
  25.  
  26. printf("Mode = %d ",maxValue);
  27.  
  28. return 0;
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
Success #stdin #stdout 0s 9424KB
stdin
6 2 12 10 12  2 12
stdout
Mode = 12