56 lines
1.2 KiB
C
56 lines
1.2 KiB
C
|
#include <stdio.h>
|
||
|
#include<string.h>
|
||
|
#define VELKOST_POLA 40
|
||
|
void error();
|
||
|
int main(){
|
||
|
int value=0;
|
||
|
int pole[VELKOST_POLA];
|
||
|
memset(pole,0,VELKOST_POLA * sizeof(int));
|
||
|
int i =0;
|
||
|
while (i<VELKOST_POLA){
|
||
|
i=i+1;
|
||
|
int r = scanf("%d",&value);
|
||
|
if (r == -1){
|
||
|
break;
|
||
|
}
|
||
|
pole[i]=value;
|
||
|
value=0;
|
||
|
}
|
||
|
int idx=0;
|
||
|
int max_hodnota=pole[0];
|
||
|
for (int j=0;pole[j]!=0;j=j+1){
|
||
|
if (pole[j]>0){
|
||
|
idx=idx+1;
|
||
|
}
|
||
|
}
|
||
|
int f=0;
|
||
|
if (idx<5){
|
||
|
error();
|
||
|
return 0;
|
||
|
}while(pole[f]!=0){
|
||
|
break;
|
||
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i+1, pole[i]);
|
||
|
}
|
||
|
printf("%d",idx);
|
||
|
int n=0;
|
||
|
while (pole[n]!=0){
|
||
|
n=n+1;
|
||
|
if (pole[n]<0){
|
||
|
break;
|
||
|
}
|
||
|
if (max_hodnota<pole[n+1]){
|
||
|
max_hodnota=pole[n+1];
|
||
|
}
|
||
|
}
|
||
|
int x=0;
|
||
|
while (pole[x]!=0){
|
||
|
x=x+1;
|
||
|
if (max_hodnota== pole[i]){
|
||
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i+1, max_hodnota);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
void error(){
|
||
|
printf("hyba: Málo platných hodnôt\n");
|
||
|
}
|