This commit is contained in:
Rudolf Zambory 2025-03-07 14:08:43 +01:00
parent 70632868b3
commit 6f1f57a384

View File

@ -26,22 +26,25 @@ int main() {
double coeffs[MAX_COEFFS];
int n = 0;
if (fgets(line, LINE_SIZE, stdin) == NULL || !is_valid_number(line)) {
fprintf(stderr, "Error: Invalid input for x.\n");
return 1;
}
double x = strtod(line, NULL);
while (fgets(line, LINE_SIZE, stdin) != NULL && line[0] != '\n') {
if (!is_valid_number(line)) {
fprintf(stderr, "Nepodarilo sa nacitat polynom na %d mieste.\n", n + 1);
continue; // Continue to allow the program to finish
return 1;
}
coeffs[n++] = strtod(line, NULL);
}
double result = horner(coeffs, n, x);
printf("Vysledok je: %.2f\n", result);
return 0; // Return 0 for successful execution
return 0;
}