Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- polynomial *calculateExp(expression *exp) {
- //TODO
- term *curkq=new term();
- polynomial *a;
- a=exp->first;
- term *cur;
- term *curnext;
- cur=a->first;
- curnext=a->next->first;
- while(a != NULL)
- {
- //---ADD------
- if( a->op = 0)
- {
- if(cur->somu >= curnext->somu)
- {
- curkq->heso=cur->heso;
- curkq->somu=cur->somu;
- curnext=curnext->next;
- }else
- {
- curkq->heso=curnext->heso;
- curkq->somu=curnext->somu;
- cur=cur->next;
- };
- initZeroPoly()->first=curkq;
- while(((cur != NULL)&&( curnext != NULL))||((cur == NULL)&&( curnext != NULL))||((cur != NULL)&&( curnext == NULL)))
- { term *kqtam=new term();
- if(cur->somu == curnext->somu)
- {
- kqtam->heso=cur->heso + curnext->heso;
- kqtam->somu=cur->somu;
- cur=cur->next;
- curnext=curnext->next;
- }else if(cur->somu > curnext->somu)
- {
- kqtam->heso=cur->heso;
- kqtam->somu=cur->somu;
- cur=cur->next;
- }else
- {
- kqtam->heso=curnext->heso;
- kqtam->somu=curnext->somu;
- curnext=curnext->next;
- };
- curkq=kqtam;
- kqtam=kqtam->next;
- };
- };
- a=a->next;
- };
- return initZeroPoly();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement