1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 15:48:42 +00:00
202401-programming-assignments/【实践课外】7.数组1/7-5 计算最大值出现的次数.c

32 lines
437 B
C
Raw Normal View History

2024-11-06 03:38:23 +00:00
#include <stdio.h>
int n, a[1005];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
int max = a[0];
for (int i = 2; i <= n; i++) {
if (a[i] > max) {
max = a[i];
}
}
int count = 0;
for (int i = 1; i <= n; i++) {
if (a[i] == max) {
count++;
}
}
printf("%d %d\n", max, count);
return 0;
}