Update 'cv3/program.c'

This commit is contained in:
Tamáš 2024-03-08 08:25:05 +00:00
parent 1369c121ed
commit 3231af40ae

View File

@ -15,12 +15,21 @@ int main() {
double coefficients[MAX_COEFFICIENTS]; double coefficients[MAX_COEFFICIENTS];
int count = 0; 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) { while (scanf("%lf", &coef) == 1) {
coefficients[count++] = coef; 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); double result = evaluatePolynomial(x, coefficients, count);
printf("Vysledok je: %.2f\n", result); printf("Vysledok je: %.2f\n", result);