diff --git a/du2/program.c b/du2/program.c index 9895d24..a2a9363 100644 --- a/du2/program.c +++ b/du2/program.c @@ -3,6 +3,7 @@ int main() { double x, koeficient, vysledok = 0; int index = 1; + int nacitane; // Nacitanie x if (scanf("%lf", &x) != 1) { @@ -13,24 +14,24 @@ int main() { // Nacitanie prvého koeficientu if (scanf("%lf", &koeficient) != 1) { printf("Nepodarilo sa nacitat polynom na %d mieste.\n", index); - return 0; // Zmenené z return 1 na return 0 + return 0; } vysledok = koeficient; index++; // Čítanie ďalších koeficientov - while (scanf("%lf", &koeficient) == 1) { + while ((nacitane = scanf("%lf", &koeficient)) == 1) { vysledok = vysledok * x + koeficient; index++; } // Ak posledné čítanie zlyhalo a nebol to EOF, znamená to nečíselný vstup - if (!feof(stdin)) { + if (nacitane == 0) { printf("Nepodarilo sa nacitat polynom na %d mieste.\n", index); - return 0; // Zmenené z return 1 na return 0 + return 0; } printf("Vysledok je: %.2f\n", vysledok); return 0; -} +} \ No newline at end of file