59 lines
1.2 KiB
C
59 lines
1.2 KiB
C
#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;
|
|
|
|
|
|
int first_read = scanf("%d", &results[0]);
|
|
if (first_read != 1) {
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
if (results[0] < 0) {
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
|
return 0;
|
|
}
|
|
|
|
|
|
value_count = 1;
|
|
max_value = results[0];
|
|
printf("Súťažiaci č. 1 vypil %d pohárov.\n", results[0]);
|
|
|
|
|
|
for (int i = 1; i < MAX_COUNT; i++) {
|
|
int r = scanf("%d", &results[i]);
|
|
if (r == 1) {
|
|
if (results[i] < 0) {
|
|
break;
|
|
}
|
|
value_count++;
|
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
|
if (results[i] > max_value) {
|
|
max_value = results[i];
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = 0; i < value_count; i++) {
|
|
if (results[i] == max_value) {
|
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n",
|
|
i + 1, max_value);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
}
|