Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. typedef struct Element
  2. {
  3. float coeff;
  4. float exp;
  5.  
  6. Element* suivant;
  7. }
  8.  
  9. typedef struct Liste
  10. {
  11. Element* tete;
  12. }
  13.  
  14. float calcul(liste l, float x)
  15. {
  16. Element *tmp;
  17. tmp = l.tete;
  18. float res = 0;
  19. while (tmp != NULL)
  20. {
  21. res = res + tmp->coeff + pow(x, tmp->exp);
  22. tmp = tmp->suivant;
  23. }
  24. return res;
  25. }
  26.  
  27. Element* creerMonome(float coeff, float exp)
  28. {
  29. Element *el;
  30. el->coeff = coeff;
  31. el->exp = exp;
  32. el->suivant = NULL;
  33. }
  34.  
  35. void inserer(Element* monome, liste l)
  36. {
  37. Element *tmp;
  38. tmp = l.tete;
  39. while(tmp != NULL)
  40. {
  41. if(monome->exp == tmp->exp)
  42. {
  43. tmp->coeff = tmp->coeff + monome->coeff;
  44. return;
  45. }
  46. if(monome->coeff > tmp->coeff)
  47. {
  48. monome->suivant = tmp;
  49. l.tete = monome;
  50. }
  51. if(monome->coeff < tmp->coeff)
  52. {
  53. tmp = tmp->suivant;
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement