try
This commit is contained in:
commit
2cf9071ed9
44
du1/program.c
Normal file
44
du1/program.c
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define VELKOST_POLA 50
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int results[VELKOST_POLA];
|
||||||
|
memset(results, 0, VELKOST_POLA * sizeof(int));
|
||||||
|
|
||||||
|
int max_value = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
printf("Zadajte výsledky súťažiacich (max %d, ukončite nečíselným vstupom alebo EOF):\n", VELKOST_POLA);
|
||||||
|
|
||||||
|
for (int i = 0; i < VELKOST_POLA; i++) {
|
||||||
|
int temp;
|
||||||
|
if (scanf("%d", &temp) != 1 || temp < 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
results[i] = temp;
|
||||||
|
if (temp > max_value) {
|
||||||
|
max_value = temp;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0) {
|
||||||
|
printf("Chyba: Málo platných hodnôt.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
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] == max_value) {
|
||||||
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user