Обновить du1/program.c
This commit is contained in:
parent
80263b9315
commit
bca95644b1
@ -1,17 +1,14 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define VELKOST_POLA 52
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int vysledky[VELKOST_POLA];
|
int results[50];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int max_hodnota = 0;
|
|
||||||
int number;
|
int number;
|
||||||
|
|
||||||
while (count < VELKOST_POLA && scanf("%d", &number) == 1) {
|
while (count < 50 && scanf("%d", &number) == 1) {
|
||||||
if (number >= 1) {
|
if (number >= 1) {
|
||||||
vysledky[count] = number;
|
results[count] = number;
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,29 +18,22 @@ int main() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
max_hodnota = vysledky[0];
|
int max_value = results[0];
|
||||||
for (int i = 1; i < count; i++) {
|
for (int i = 1; i < count; i++) {
|
||||||
if (vysledky[i] > max_hodnota) {
|
if (results[i] > max_value) {
|
||||||
max_hodnota = vysledky[i];
|
max_value = results[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, vysledky[i]);
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Výherca je súťažiaci ");
|
|
||||||
int isFirst = 1;
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (vysledky[i] == max_hodnota) {
|
if (results[i] == max_value) {
|
||||||
if (!isFirst) {
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
|
||||||
printf(" a ");
|
|
||||||
}
|
|
||||||
printf("súťažiaci %d", i + 1);
|
|
||||||
isFirst = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(" ktorý vypil %d pohárov.\n", max_hodnota);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user