Advertisement
Guest User

Untitled

a guest
May 26th, 2015
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. polynomial *calculateExp(expression *exp) {
  2. //TODO
  3. term *curkq=new term();
  4. polynomial *a;
  5. a=exp->first;
  6. term *cur;
  7. term *curnext;
  8. cur=a->first;
  9. curnext=a->next->first;
  10.  
  11. while(a != NULL)
  12. {
  13. //---ADD------
  14. if( a->op = 0)
  15. {
  16. if(cur->somu >= curnext->somu)
  17. {
  18. curkq->heso=cur->heso;
  19. curkq->somu=cur->somu;
  20. curnext=curnext->next;
  21. }else
  22. {
  23. curkq->heso=curnext->heso;
  24. curkq->somu=curnext->somu;
  25. cur=cur->next;
  26. };
  27. initZeroPoly()->first=curkq;
  28. while(((cur != NULL)&&( curnext != NULL))||((cur == NULL)&&( curnext != NULL))||((cur != NULL)&&( curnext == NULL)))
  29. { term *kqtam=new term();
  30. if(cur->somu == curnext->somu)
  31. {
  32. kqtam->heso=cur->heso + curnext->heso;
  33. kqtam->somu=cur->somu;
  34. cur=cur->next;
  35. curnext=curnext->next;
  36. }else if(cur->somu > curnext->somu)
  37. {
  38. kqtam->heso=cur->heso;
  39. kqtam->somu=cur->somu;
  40. cur=cur->next;
  41. }else
  42. {
  43. kqtam->heso=curnext->heso;
  44. kqtam->somu=curnext->somu;
  45. curnext=curnext->next;
  46. };
  47. curkq=kqtam;
  48. kqtam=kqtam->next;
  49. };
  50. };
  51. a=a->next;
  52. };
  53.  
  54. return initZeroPoly();
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement