39 lines
1.1 KiB
C
39 lines
1.1 KiB
C
#include <stdio.h>
|
|
#define maxcol 50
|
|
|
|
int main() {
|
|
int results[maxcol];
|
|
int count = 0;
|
|
int num;
|
|
|
|
while (count < maxcol && scanf("%d", &num) == 1) {
|
|
if (num < 1) {
|
|
break;
|
|
}
|
|
results[count] = num;
|
|
count++; //нумерация чисел
|
|
}
|
|
|
|
if (count == 0) { //если не было введено никакое число
|
|
printf("Chyba: Malo platnych hodnot.\n");
|
|
return 0;
|
|
}
|
|
|
|
for (int i = 0; i < count; i++) { //выписывание всех чисел
|
|
printf("Sutaziaci c. %d vypil %d poharov.\n",i+1,results[i]);
|
|
}
|
|
|
|
int max_value = results[0];
|
|
for (int i = 1; i < count; i++) {
|
|
if (results[i] > max_value) {
|
|
max_value = results[i];
|
|
}
|
|
}
|
|
for (int i = 0; i < count; i++) {
|
|
if (results[i] == max_value) {
|
|
printf("Vyherca je sutaziaci %d ktory vypil %d poharov.\n",i+1,results[i]);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|