pvjc25/du1/program.c

39 lines
828 B
C
Raw Normal View History

2025-02-28 06:56:35 +00:00
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_COUNT 50
int main() {
int results[MAX_COUNT] = {0};
int max_value = 0;
int value_count = 0;
for (int i = 0; i < MAX_COUNT; i++) {
int r = scanf("%d", &results[i]);
if (r == 1) {
value_count++;
if (results[i] > max_value) {
max_value = results[i];
}
} else {
break;
}
}
if (value_count == 0) {
printf("Žiadne hodnoty neboli načítané.\n");
return 1;
}
printf("Maximálna hodnota bola %d.\n", max_value);
for (int i = 0; i < value_count; i++) {
if (results[i] == max_value) {
printf("Súťažiaci číslo %d dosiahol maximálnu hodnotu.\n", i + 1);
}
}
return 0;
}