Update 'cv2/program.c'

This commit is contained in:
Tamáš 2024-02-29 10:18:27 +00:00
parent a11eba70f8
commit b61828b8d6

View File

@ -1,27 +1,34 @@
#include <stdio.h>
int main() {
int results[50], count = 0, num, maxPoharov = 0;
int results[50];
int count = 0, num;
int maxPoharov = 0;
int maxIndex = -1;
while (count < 50 && scanf("%d", &num) == 1) {
if (num < 1) {
continue;
if (num <= 0) {
break;
}
results[count++] = num;
results[count] = num;
if (num > maxPoharov) {
maxPoharov = num;
maxIndex = count;
}
count++;
}
for (int i = 0; i < count; i++) {
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, 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);
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);
}
}
}