test
This commit is contained in:
parent
5a74eaae4d
commit
aef5c8ee4d
37
cv2/program.c
Normal file
37
cv2/program.c
Normal file
@ -0,0 +1,37 @@
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
int main() {
|
||||
int results[50], count = 0, num, maxPoharov = 0;
|
||||
|
||||
while (scanf("%d", &num) == 1) {
|
||||
if (num < 1 || num > 50) {
|
||||
printf("Chyba: Neplatné číslo.\n");
|
||||
return 0;
|
||||
}
|
||||
if (count >= 50) {
|
||||
break;
|
||||
}
|
||||
results[count++] = num;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
printf("Chyba: Málo platných hodnôt.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
||||
if (results[i] > maxPoharov) {
|
||||
maxPoharov = results[i];
|
||||
}
|
||||
}
|
||||
|
||||
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