From 5619d453a37f7acc961ed8bb945064a342dd623d Mon Sep 17 00:00:00 2001 From: VIliam Date: Tue, 27 Feb 2024 10:13:05 +0100 Subject: [PATCH] schema --- cv3/program.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cv3/program.c b/cv3/program.c index be66fe6..03db213 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -8,7 +8,9 @@ bool IsValidNumber(const char *line) { char *endFtr; strtod(line, &endFtr); - return *endFtr == '\0'; + if (endPtr == line){ + return false; + } } int main() { @@ -23,7 +25,6 @@ int main() { } while (1) { - printf("Zadajte polynom na %d mieste: ", coefficientIndex); if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { printf("Nepodarilo sa nacitat polynom na %d mieste. \n", coefficientIndex); return 1; @@ -36,11 +37,10 @@ int main() { return 1; } - result = result * x; - coefficientIndex++; + result = result * x + coeffiecientIndex; } - printf("Vysledok je: %f\n", result); + printf("Vysledok je: %.2f\n", result); return 0; }