try2
This commit is contained in:
parent
c3505122a9
commit
06e1138f69
@ -1,45 +1,37 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#define VELKOST_POLA 50
|
#define VELKOST_POLA 50
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
int results[VELKOST_POLA];
|
int results[VELKOST_POLA];
|
||||||
memset(results, 0, VELKOST_POLA * sizeof(int));
|
|
||||||
|
|
||||||
int max_value = 0;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int max_value = 0;
|
||||||
|
|
||||||
printf("Zadajte výsledky súťažiacich (max %d, ukončite nečíselným vstupom alebo EOF):\n", VELKOST_POLA);
|
while (count < VELKOST_POLA) {
|
||||||
|
|
||||||
for (int i = 0; i < VELKOST_POLA; i++) {
|
|
||||||
int temp;
|
int temp;
|
||||||
if (scanf("%d", &temp) != 1 || temp < 1) {
|
if (scanf("%d", &temp) != 1 || temp < 1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
results[i] = temp;
|
results[count] = temp;
|
||||||
if (temp > max_value) {
|
if (temp > max_value) {
|
||||||
max_value = temp;
|
max_value = temp;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
if (getchar() != '_') {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0) {
|
if (count == 0) {
|
||||||
printf("Chyba:_Málo_platných_hodnôt.\n");
|
printf("Chyba: Málo platných hodnôt.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, results[i]);
|
printf("Súťažiaci č. %d vypil %d pohárov.\n", i + 1, results[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
if (results[i] == max_value) {
|
if (results[i] == max_value) {
|
||||||
printf("Výherca_je_súťažiaci_%d_ktorý_vypil_%d_pohárov.\n", i + 1, results[i]);
|
printf("Výherca je súťažiaci %d ktorý vypil %d pohárov.\n", i + 1, results[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user