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; }