Fixed polynomial print sign of first element
This commit is contained in:
parent
c0c5e219ea
commit
f08e2e6b35
6
main.c
6
main.c
@ -57,7 +57,7 @@ void simplify_polynomial(double *res, double *el_coef, double *x, unsigned int n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* `res` is an array of coefficients of polynomial which is multiplied with (x - `root`) polynomial
|
/* `res` is an array of coefficients of polynomial, which is multiplied with (x - `root`) polynomial.
|
||||||
`power` is the power of `res` polynomial */
|
`power` is the power of `res` polynomial */
|
||||||
void mult_by_root(double *res, double root, unsigned int power)
|
void mult_by_root(double *res, double root, unsigned int power)
|
||||||
{
|
{
|
||||||
@ -145,7 +145,7 @@ void print_array(double *arr, unsigned int n)
|
|||||||
|
|
||||||
void print_poly(double *coef, unsigned int n)
|
void print_poly(double *coef, unsigned int n)
|
||||||
{
|
{
|
||||||
printf("Simplified polynom:\n");
|
printf("Simplified polynomial:\n");
|
||||||
|
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
@ -156,7 +156,7 @@ void print_poly(double *coef, unsigned int n)
|
|||||||
printf("+ ");
|
printf("+ ");
|
||||||
else
|
else
|
||||||
printf("- ");
|
printf("- ");
|
||||||
else
|
else if (coef[i] < 0)
|
||||||
printf("-");
|
printf("-");
|
||||||
|
|
||||||
printf("%lf", fabs(coef[i]));
|
printf("%lf", fabs(coef[i]));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user