2020-03-02 13:52:42 +00:00
|
|
|
#include <stdio.h>
|
2020-03-02 19:16:10 +00:00
|
|
|
#define VELKOST_POLA 50
|
2020-03-02 13:52:42 +00:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int pole[VELKOST_POLA] = {0,0,0,0};
|
|
|
|
|
2020-03-02 19:29:12 +00:00
|
|
|
int i = 0, max_hodnota = 0, value = 0;
|
|
|
|
|
2020-03-02 19:35:29 +00:00
|
|
|
while(value >= 0 && i <= 49 && value != EOF){
|
2020-03-02 19:16:10 +00:00
|
|
|
int r = scanf("%d",&value);
|
|
|
|
|
|
|
|
if(value <= -1){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(max_hodnota < value){
|
|
|
|
max_hodnota = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(r == 1){
|
|
|
|
pole[i] = value;
|
|
|
|
i++;
|
|
|
|
|
|
|
|
fprintf(stdout, "Súťažiaci č. %d vypil %d pohárov.\n", i, pole[i-1]);
|
|
|
|
} else{
|
|
|
|
break;
|
2020-03-02 13:52:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-02 19:38:28 +00:00
|
|
|
if(value <= -1 && i == 0){
|
2020-03-02 19:39:56 +00:00
|
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
2020-03-02 19:39:19 +00:00
|
|
|
return 0;
|
2020-03-02 19:37:16 +00:00
|
|
|
}
|
|
|
|
|
2020-03-02 19:33:22 +00:00
|
|
|
// TUKE, WHY I CANT printf THIS RESULT BUT IN A DIFFERENT ORDER? 0_0 ```for(; i >= 0; i--)``` ---> pls fix this
|
|
|
|
int j = 0;
|
|
|
|
for(;j <= i; j++){
|
|
|
|
if(pole[j] == max_hodnota){
|
|
|
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", j+1, pole[j]);
|
2020-03-02 19:29:12 +00:00
|
|
|
}
|
|
|
|
}
|
2020-03-02 13:52:42 +00:00
|
|
|
|
|
|
|
return 0;
|
2020-02-26 10:03:57 +00:00
|
|
|
}
|
2020-03-02 13:52:42 +00:00
|
|
|
|
2020-03-02 19:16:10 +00:00
|
|
|
|