Обновить du2/program.c
This commit is contained in:
parent
d091362935
commit
29baf2a6fe
@ -12,7 +12,7 @@ int read_double(double *value, int coef_index) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
line[strcspn(line, "\r\n")] = 0;
|
line[strcspn(line, "\r\n")] = 0;
|
||||||
|
|
||||||
if (strlen(line) == 0) {
|
if (strlen(line) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -36,6 +36,7 @@ int read_double(double *value, int coef_index) {
|
|||||||
int main() {
|
int main() {
|
||||||
double x;
|
double x;
|
||||||
|
|
||||||
|
// Read base `x`
|
||||||
if (!read_double(&x, 1)) {
|
if (!read_double(&x, 1)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -46,6 +47,7 @@ int main() {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
coef_count++;
|
coef_count++;
|
||||||
|
|
||||||
int status = read_double(&coef, coef_count);
|
int status = read_double(&coef, coef_count);
|
||||||
|
|
||||||
if (status == -1) {
|
if (status == -1) {
|
||||||
@ -54,7 +56,7 @@ int main() {
|
|||||||
|
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
if (coef_count == 1) {
|
if (coef_count == 1) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -62,6 +64,6 @@ int main() {
|
|||||||
result = result * x + coef;
|
result = result * x + coef;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Vysledok je: %.2f\n", result);
|
printf("Vysledok je: %.2f\n", result);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user