#include #include #include #define LINE_SIZE 100 int main() { char line[LINE_SIZE]; double x, result; double coefficient; int first = 1; // Read the evaluation point if (fgets(line, LINE_SIZE, stdin) == NULL || sscanf(line, "%lf", &x) != 1) { printf("Chyba: Neplatná hodnota pre x.\n"); return 1; } result = 0; // Read coefficients until EOF or an empty line while (fgets(line, LINE_SIZE, stdin) != NULL) { if (strlen(line) <= 1) break; // Empty line check if (sscanf(line, "%lf", &coefficient) != 1) { printf("Chyba: Neplatný koeficient.\n"); return 1; } if (first) { result = coefficient; first = 0; } else { result = result * x + coefficient; } } if (first) { printf("Chyba: Neboli zadané žiadne koeficienty.\n"); return 1; } // Print result rounded to two decimal places printf("Vysledok je: %.2f\n", result); return 0; }