Update 'cv2/program.c'
This commit is contained in:
parent
b61828b8d6
commit
84bec1c7d2
@ -4,7 +4,6 @@ int main() {
|
||||
int results[50];
|
||||
int count = 0, num;
|
||||
int maxPoharov = 0;
|
||||
int maxIndex = -1;
|
||||
|
||||
while (count < 50 && scanf("%d", &num) == 1) {
|
||||
if (num <= 0) {
|
||||
@ -13,24 +12,26 @@ int main() {
|
||||
results[count] = num;
|
||||
if (num > maxPoharov) {
|
||||
maxPoharov = num;
|
||||
maxIndex = count;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
|
||||
if (count == 0) {
|
||||
printf("Chyba: Málo platných hodnôt.\n");
|
||||
return 0; // Ukončí program
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
||||
}
|
||||
|
||||
|
||||
if (maxIndex != -1) {
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
if (results[i] == maxPoharov) {
|
||||
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, maxPoharov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user