rendered paste body#include "rezult_medis.h"void rezult_medis::skleiskk1(node2 *p){ if (p) { skleiskk1 (p->left); cout << p->preke << " " << p->likutis << " " << p->pard_kaina << " " << p->pajamos << endl; skleiskk1 (p->right); } //else cout << "medis tuscias";}node2* rezult_medis::newnode1(node2* nod){ node2* n = new node2; n->preke = nod->preke; n->likutis = nod->likutis; n->pard_kaina = nod->pard_kaina; n->pajamos = nod->pajamos; n->left = NULL; n->right = NULL; return n;}void rezult_medis :: put (node2* str){ if (root == NULL) { root = newnode1(str); } else { node2 *cur = root; while (true) { if(cur->pard_kaina < str->pard_kaina) { if (cur->right == NULL) { cur->right = newnode1(str); break; } else cur = cur->right; } else if (cur->pard_kaina > str->pard_kaina) { if (cur->left == NULL) { cur->left = newnode1(str); break; } else cur = cur->left; } else break; }; }}void rezult_medis::atrinkimas(){ stack A; medis B; int m; node* tmp = new node; node1* temp = new node1; node2* temp1 = new node2; m = A.add(); B.add(); for (int i=0; i<m; i++) { if(tmp = A.atrinkimas()){ //cout << tmp->preke << " " << tmp->gaut_kiek << " " << tmp->pard_kiek << " " << tmp->date << endl; temp = B.get(tmp->preke); temp1->preke = temp->preke; temp1->likutis = tmp->gaut_kiek - tmp->pard_kiek; temp1->pard_kaina = temp->kaina; temp1->pajamos = (temp->kaina) * (tmp->pard_kiek); put(temp1); } } rodyk();}