From 3231af40ae26ea9f3d7050dfa1a04188081c6ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1=C5=A1?= Date: Fri, 8 Mar 2024 08:25:05 +0000 Subject: [PATCH] Update 'cv3/program.c' --- cv3/program.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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);