Files
42_EXT_05_computorv1/src/reducer.c
2026-05-07 13:18:28 +02:00

28 lines
492 B
C

/* reduce.c */
#include "computorv1.h"
void reduce(s_term *terms, double *polynom)
{
int i;
int exponent;
double tmp;
i = 0;
while (terms[i].position != TERM_END)
{
// get coefficient with left sign
tmp = terms[i].coefficient;
if (terms[i].position == TERM_RIGHT)
{
tmp *= -1;
}
// add coefficient to exponent
exponent = terms[i].exponent;
polynom[exponent] += tmp;
i++;
}
}