pvjc24/cv2/program.c

30 lines
655 B
C
Raw Normal View History

2024-02-27 14:10:58 +00:00
#include <stdio.h>
int main() {
int results[50], count = 0, num, maxPoharov = 0;
2024-02-29 09:30:25 +00:00
while (count < 50 && scanf("%d", &num) == 1) {
2024-02-29 09:24:04 +00:00
if (num < 1) {
2024-02-29 09:30:25 +00:00
continue;
2024-02-27 14:10:58 +00:00
}
results[count++] = num;
2024-02-29 09:32:05 +00:00
if (num > maxPoharov) {
maxPoharov = num;
}
2024-02-27 14:10:58 +00:00
}
for (int i = 0; i < count; i++) {
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
}
2024-02-29 09:26:37 +00:00
2024-02-27 14:10:58 +00:00
for (int i = 0; i < count; i++) {
if (results[i] == maxPoharov) {
2024-02-29 09:22:06 +00:00
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, maxPoharov);
2024-02-27 14:10:58 +00:00
}
}
return 0;
}