Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- typedef struct Element
- {
- float coeff;
- float exp;
- Element* suivant;
- }
- typedef struct Liste
- {
- Element* tete;
- }
- float calcul(liste l, float x)
- {
- Element *tmp;
- tmp = l.tete;
- float res = 0;
- while (tmp != NULL)
- {
- res = res + tmp->coeff + pow(x, tmp->exp);
- tmp = tmp->suivant;
- }
- return res;
- }
- Element* creerMonome(float coeff, float exp)
- {
- Element *el;
- el->coeff = coeff;
- el->exp = exp;
- el->suivant = NULL;
- }
- void inserer(Element* monome, liste l)
- {
- Element *tmp;
- tmp = l.tete;
- while(tmp != NULL)
- {
- if(monome->exp == tmp->exp)
- {
- tmp->coeff = tmp->coeff + monome->coeff;
- return;
- }
- if(monome->coeff > tmp->coeff)
- {
- monome->suivant = tmp;
- l.tete = monome;
- }
- if(monome->coeff < tmp->coeff)
- {
- tmp = tmp->suivant;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement