/* reduce.c */

#include "computorv1.h"

void reduce(s_term *terms, s_polynom *polynom)
{
    int i;
    double tmp;

    i = 0;
    while (terms[i].position != TERM_END)
    {
        tmp = terms[i].coefficient;
        if (terms[i].position == TERM_RIGHT)
        {
            tmp *= -1;
        }
        if (terms[i].exponent == 2)
        {
            polynom->a += tmp;
        }
        if (terms[i].exponent == 1)
        {
            polynom->b += tmp;
        }
        if (terms[i].exponent == 0)
        {
            polynom->c += tmp;
        }
        i++;
    }
}