From d478fb09b2f668e41d7d4f2088937bd45a5d3ec8 Mon Sep 17 00:00:00 2001 From: VIliam Date: Wed, 28 Feb 2024 15:49:44 +0100 Subject: [PATCH] schema --- cv3/program.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index 5e8b37b..8ce63a6 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -21,6 +21,8 @@ int main() { return 1; } + double x_base = strtod(line, NULL); + while (1) { if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { if (line[0] == '\n') { @@ -31,17 +33,16 @@ int main() { } char *endPtr; - double x = strtod(line, &endPtr); + double coefficient = strtod(line, &endPtr); if (*endPtr != '\n' && *endPtr != '\0') { printf("Nespravny format cisla\n"); return 1; } - result = result * x; + result = result * x_base + coefficient; coefficientIndex++; } printf("Vysledok je: %.2f\n", result); return 0; } -