diff --git a/cv3/program.c b/cv3/program.c index 5eb465a..07b0a09 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -15,12 +15,21 @@ int main() { double coefficients[MAX_COEFFICIENTS]; int count = 0; - scanf("%lf", &x); + if (scanf("%lf", &x) != 1) { + printf("Nepodarilo sa nacitat hodnotu x.\n"); + return 1; + } while (scanf("%lf", &coef) == 1) { coefficients[count++] = coef; } + + if (!feof(stdin)) { + printf("Nepodarilo sa nacitat polynom na %d mieste.\n", count + 1); + return 1; + } + double result = evaluatePolynomial(x, coefficients, count); printf("Vysledok je: %.2f\n", result);