48 lines
1.0 KiB
C
48 lines
1.0 KiB
C
#include <stdio.h>
|
|
#define VELKOST_POLA 50
|
|
|
|
int main()
|
|
{
|
|
int pole[VELKOST_POLA] = {0,0,0,0};
|
|
|
|
int i = 0, max_hodnota = 0, value = 0;
|
|
|
|
while(value >= 0 && i <= 49 && value != EOF){
|
|
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;
|
|
}
|
|
}
|
|
|
|
if(i == 0){
|
|
printf("Chyba: Málo platných hodnôt.\n");
|
|
return 0;
|
|
}
|
|
|
|
// 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]);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
|