Сделал 45 Задание
This commit is contained in:
parent
dae8abd5cc
commit
f677c28eb4
7 changed files with 99 additions and 0 deletions
20
45Ex/solve_polynomial.c
Normal file
20
45Ex/solve_polynomial.c
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include "solve_polynomial.h"
|
||||
|
||||
int solvePolynomial(FILE * file, double x, double * derivative, double * polynomial) {
|
||||
double current, i;
|
||||
|
||||
if (fscanf(file, "%lf", ¤t) != 1) {
|
||||
printf("File is empty!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
*derivative = *polynomial = i = 0.;
|
||||
|
||||
do {
|
||||
*polynomial += current * pow(x, i);
|
||||
*derivative += i * current * pow(x, i - 1);
|
||||
i++;
|
||||
} while (fscanf(file, "%lf", ¤t) == 1);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue