From f08e2e6b35fc9dba9b1e060ff15ca2c371d735a0 Mon Sep 17 00:00:00 2001 From: dm1sh Date: Sun, 31 Oct 2021 16:56:49 +0300 Subject: [PATCH] Fixed polynomial print sign of first element --- main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.c b/main.c index 5987363..04df645 100644 --- a/main.c +++ b/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 */ 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) { - printf("Simplified polynom:\n"); + printf("Simplified polynomial:\n"); for (int i = 0; i < n; i++) { @@ -156,7 +156,7 @@ void print_poly(double *coef, unsigned int n) printf("+ "); else printf("- "); - else + else if (coef[i] < 0) printf("-"); printf("%lf", fabs(coef[i]));