整数出现次数.c 572 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <stdio.h>
  2. int main() {
  3. int n, i;
  4. scanf("%d", &n);
  5. int arr[100];
  6. for (i = 0; i < n; i++) {
  7. scanf("%d", &arr[i]);
  8. }
  9. int count[10000*2+1] = {0};
  10. for (i = 0; i < n; i++) {
  11. count[arr[i] + 10000]++;
  12. }
  13. int max_count = 0;
  14. for (i = 0; i < 10000*2+1; i++) {
  15. if (count[i] > max_count) {
  16. max_count = count[i];
  17. }
  18. }
  19. for (i = 0; i < 10000*2+1; i++) {
  20. if (count[i] == max_count) {
  21. printf("%d %d\n", i - 10000, max_count);
  22. }
  23. }
  24. return 0;
  25. }