zmeny
This commit is contained in:
parent
32191ae5ab
commit
699c42b072
@ -3,20 +3,19 @@
|
|||||||
#define VELKOST_POLA 52
|
#define VELKOST_POLA 52
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
int pole[VELKOST_POLA];
|
int pole[VELKOST_POLA]; // deklarácia poľa
|
||||||
|
memset(pole,0,VELKOST_POLA * sizeof(int)); // inicializácia poľa nulami
|
||||||
|
|
||||||
memset(pole,0,VELKOST_POLA * sizeof(int));
|
int participant_count = 0; // počet účastníkov
|
||||||
|
|
||||||
int participant_count = 0;
|
|
||||||
for (int i = 0; i < VELKOST_POLA; ++i) {
|
for (int i = 0; i < VELKOST_POLA; ++i) {
|
||||||
int value = 0;
|
int value = 0; // premenná, v ktorej sa bude uchovávať hodnota zadaná používateľom
|
||||||
int r = scanf("%d", &value);
|
int r = scanf("%d", &value); // uloženie tejto hodnoty
|
||||||
if(r > 0 && value > 0) {
|
if(r > 0 && value > 0) { // kontrola hodnoty na kladné číslo
|
||||||
pole[i] = value;
|
pole[i] = value; // inicializácia poľa už potrebnými hodnotami
|
||||||
participant_count++;
|
participant_count++; // zvýšenie počtu účastníkov
|
||||||
} else {
|
} else {
|
||||||
if(participant_count == 0) {
|
if(participant_count == 0) { // ak používateľ nezadal alebo zadal nesprávnu hodnotu, zobrazí sa chyba
|
||||||
printf("Chyba: Málo platných hodnôt.\n");
|
printf("Chyba: Málo platných hodnôt.\n");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -25,7 +24,6 @@ int main() {
|
|||||||
|
|
||||||
int best_result = pole[0];
|
int best_result = pole[0];
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < participant_count; ++i) {
|
for (int i = 0; i < participant_count; ++i) {
|
||||||
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, pole[i]);
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, pole[i]);
|
||||||
if(best_result < pole[i]) {
|
if(best_result < pole[i]) {
|
||||||
@ -33,12 +31,12 @@ int main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < participant_count; ++i) {
|
for (int i = 0; i < participant_count; ++i) {
|
||||||
if(pole[i] == best_result) {
|
if(pole[i] == best_result) {
|
||||||
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, best_result);
|
printf("Výherca je súťažiaci %d, ktorý vypil %d pohárov.\n", i + 1, best_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user