try3
This commit is contained in:
parent
06e1138f69
commit
bc79f9792c
@ -1,23 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define VELKOST_POLA 50
|
||||
|
||||
int main() {
|
||||
int results[VELKOST_POLA];
|
||||
int results[50];
|
||||
int count = 0;
|
||||
int max_value = 0;
|
||||
int value;
|
||||
|
||||
while (count < VELKOST_POLA) {
|
||||
int temp;
|
||||
if (scanf("%d", &temp) != 1 || temp < 1) {
|
||||
printf("Zadajte výsledky súťaže (max 50 hodnôt, ukončite EOF alebo neplatným číslom):\n");
|
||||
|
||||
while (scanf("%d", &value) == 1) {
|
||||
if (value < 1) {
|
||||
break;
|
||||
}
|
||||
results[count] = temp;
|
||||
if (temp > max_value) {
|
||||
max_value = temp;
|
||||
results[count++] = value;
|
||||
if (count >= 50) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
@ -29,9 +27,17 @@ int main() {
|
||||
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
||||
}
|
||||
|
||||
int max = results[0];
|
||||
for (int i = 1; i < count; i++) {
|
||||
if (results[i] > max) {
|
||||
max = results[i];
|
||||
}
|
||||
}
|
||||
|
||||
printf("Výherca je:\n");
|
||||
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]);
|
||||
if (results[i] == max) {
|
||||
printf("Súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user