Доделал 46е задание
This commit is contained in:
parent
5d875464a3
commit
973e407a45
6 changed files with 41 additions and 21 deletions
22
46Ex/main.c
22
46Ex/main.c
|
@ -1,5 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include "tools.h"
|
||||
#include "solution_polynomial.h"
|
||||
|
||||
/*
|
||||
Example: 5 4 3 2 1
|
||||
|
@ -9,27 +10,6 @@ Answer: 80 + 32 + 12 + 4 + 1 = 129
|
|||
160 + 48 + 12 + 2 = 222
|
||||
*/
|
||||
|
||||
int solutionPolynomial(FILE * file, double x, double * derivative, double * polynomial);
|
||||
|
||||
int solutionPolynomial(FILE * file, double x, double * derivative, double * polynomial) {
|
||||
double current;
|
||||
|
||||
if (fscanf(file, "%lf", ¤t) != 1) {
|
||||
printf("File is empty!");
|
||||
return 1;
|
||||
}
|
||||
|
||||
*derivative = *polynomial = 0;
|
||||
|
||||
do {
|
||||
*derivative = *derivative * x + *polynomial;
|
||||
*polynomial = *polynomial * x + current;
|
||||
// c4x^3 + c3x^2 + c2x + c = c = c2x + c = c3x^2 + c2x + c = ...
|
||||
} while (fscanf(file, "%lf", ¤t) == 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
double x, derivative, polynomial;
|
||||
FILE * file = getFile();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue