du1
This commit is contained in:
parent
1e503d7c7f
commit
ccb415a4eb
40
du1/program.c
Normal file
40
du1/program.c
Normal file
@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define ARRAY_SIZE 52
|
||||
|
||||
int main() {
|
||||
int results[ARRAY_SIZE];
|
||||
memset(results, 0, ARRAY_SIZE * sizeof(int));
|
||||
|
||||
int index = 0;
|
||||
int max_value = 0;
|
||||
int value;
|
||||
|
||||
while (scanf("%d", &value) == 1 && value > 0) {
|
||||
if (index >= ARRAY_SIZE) {
|
||||
fprintf(stderr, "Error: Too many competitors!\n");
|
||||
return 1;
|
||||
}
|
||||
results[index] = value;
|
||||
if (value > max_value) {
|
||||
max_value = value;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
if (index == 0) {
|
||||
printf("No valid data were entered.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Competitors with the highest number of drinks:\n");
|
||||
for (int i = 0; i < index; i++) {
|
||||
if (results[i] == max_value) {
|
||||
printf("%d\n", i);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user