#include #include #include #include #define LINE_SIZE 100 int read_double(double *value) { char line[LINE_SIZE]; if (fgets(line, LINE_SIZE, stdin) == NULL) { return 0; // Chyba pri čítaní } char *endptr; *value = strtod(line, &endptr); if (endptr == line || (*endptr != '\0' && *endptr != '\n')) { return 0; // Neplatný vstup } return 1; } int main() { double x; if (!read_double(&x)) { printf("Chyba: Nepodarilo sa načítať hodnotu x.\n"); return 1; } double coef; double result = 0; int coef_count = 0; while (1) { if (!read_double(&coef)) { if (coef_count == 0) { printf("Chyba: Neboli zadané žiadne koeficienty.\n"); return 1; } break; } result = result * x + coef; coef_count++; } printf("Vysledok je: %.2f\n", result); return 0; }