This commit is contained in:
Džubara 2024-02-28 15:58:29 +01:00
parent 0bff677e4f
commit 13a514d406

View File

@ -16,14 +16,13 @@ int main() {
double result = 0; double result = 0;
int exponent = 2; int exponent = 2;
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
printf("Nepodarilo sa nacitat zaklad x\n"); printf("Nepodarilo sa nacitat zaklad x\n");
return 1; return 1;
} }
double x = strtod(line, NULL); double x = strtod(line, NULL);
result += x; result += 1;
while (1) { while (1) {
if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) { if (fgets(line, MAX_LINE_LENGTH, stdin) == NULL || !IsValidNumber(line)) {
@ -35,7 +34,7 @@ int main() {
} }
x = strtod(line, NULL); x = strtod(line, NULL);
result += x * exponent; result = result * x + 1;
exponent--; exponent--;
} }