fork download
  1. #include <stdio.h>
  2. #include <limits.h>
  3.  
  4. int CountMaxIntValue(FILE *f)
  5. {
  6. int x, maximum, count;
  7. count = 0;
  8. maximum = INT_MIN;
  9.  
  10. while (fscanf(f, "%d", &x) == 1)
  11. {
  12. if (x > maximum)
  13. {
  14. maximum = x;
  15. count = 1;
  16. }
  17. else if (x == maximum)
  18. {
  19. count++;
  20. }
  21. }
  22. return count;
  23. }
  24.  
  25. int main(void) {
  26. printf("%d\n", CountMaxIntValue(stdin));
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 9432KB
stdin
1 2 7 3 4 5 7
stdout
2