update file structure

This commit is contained in:
hugogogo
2026-05-06 17:51:07 +02:00
parent 0046409c89
commit 4b6ad34720
5 changed files with 172 additions and 162 deletions

27
src/reducer.c Normal file
View File

@@ -0,0 +1,27 @@
/* 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++;
}
}