44 lines
964 B
C
44 lines
964 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <limits.h>
|
|
|
|
#define MAX_SIZE 50
|
|
|
|
int main() {
|
|
int results[MAX_SIZE];
|
|
int count = 0;
|
|
int num;
|
|
|
|
while (count < MAX_SIZE && scanf("%d", &num) == 1) {
|
|
if (num < 1) {
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
|
return 1;
|
|
}
|
|
results[count++] = num;
|
|
}
|
|
|
|
if (count == 0) {
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
|
return 1;
|
|
}
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
|
}
|
|
|
|
int max_val = INT_MIN;
|
|
for (int i = 0; i < count; i++) {
|
|
if (results[i] > max_val) {
|
|
max_val = results[i];
|
|
}
|
|
}
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
if (results[i] == max_val) {
|
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|