diff --git a/cv3/program.c b/cv3/program.c index 33f32c1..68cf33e 100644 --- a/cv3/program.c +++ b/cv3/program.c @@ -14,8 +14,7 @@ bool IsValidNumber(const char *line) { int main() { char line[MAX_LINE_LENGTH]; double result = 0; - int exponent = 2; - + int exponent = 2; if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { printf("Nepodarilo sa nacitat zaklad x\n"); @@ -23,7 +22,7 @@ int main() { } double x = strtod(line, NULL); - result += x; + result += 1; while (1) { if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { @@ -35,9 +34,9 @@ int main() { } x = strtod(line, NULL); - result += x * exponent; + result = result * x + 1; - exponent--; + exponent--; } printf("Vysledok je: %.2f\n", result);