pvjc24/cv2/program.c

39 lines
804 B
C
Raw Normal View History

2024-02-22 13:35:42 +00:00
#include<stdio.h>
#define FIELD_SIZE 52
2024-02-28 12:49:54 +00:00
int main(){
int field[FIELD_SIZE] = {0};
int count = 0;
int max_num = 0;
int input;
while (count < FIELD_SIZE) {
if (scanf("%d", &input) != 1) {
break;
}
if (input < 0) {
2024-02-28 13:30:10 +00:00
printf("Chyba: Málo platných hodnôt.\n");
2024-02-28 13:27:14 +00:00
break;
2024-02-28 12:49:54 +00:00
}
field[count] = input;
count++;
}
for (int i = 0; i < count; i++) {
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, field[i]);
if (field[i] > max_num) {
max_num = field[i];
}
}
2024-02-28 13:17:46 +00:00
for (int i = 0; i < count; i++) {
if (field[i] == max_num) {
2024-02-28 13:21:08 +00:00
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n",i+1, max_num);
2024-02-28 13:17:46 +00:00
}
}
2024-02-28 12:23:11 +00:00
return 0;
2024-02-28 13:34:00 +00:00
}
2024-02-28 13:30:10 +00:00