28 lines
492 B
C
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++;
|
|
}
|
|
} |