• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Mar 24th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Polinom Polinom :: operator+(const Polinom &A) const {
2.     /// Supraincarcarea operatorului de adunare - Adunarea dintre doua polinoame.
3.
4.     // Daca unul dintre polinoame este nul, il returnez pe celalalt.
5.     if (Max == NULL) return A;
6.     Polinom Result;
7.     if (A.Max == NULL) {
8.         Result.Max = Result.Min = NULL;
9.         return Result;
10.     }
11.     Nod *P = Min, *Q = A.Min, *R;
12.     bool OK = true;
13.     while (Q != NULL || P != NULL) {
14.         Result.Max = new Nod;
15.         if (OK == true) {
16.             R = Result.Min = Result.Max;
17.             OK = false;
18.         }
19.         if (P == NULL || Q->Grad < P->Grad) {
20.             Result.Max->Info = Q->Info;
21.             Result.Max->Grad = Q->Grad;
22.             Q = Q->Prev;
23.         }
24.         else if (Q == NULL || Q->Grad > P->Grad) {
25.             Result.Max->Info = P->Info;
26.             Result.Max->Grad = P->Grad;
27.             P = P->Prev;
28.         }
29.         else {
30.             Result.Max->Grad = P->Grad;
31.             Result.Max->Info = P->Info + Q->Info;
32.             P = P->Prev;
33.             Q = Q->Prev;
34.         }
35.         if (OK == false) {
36.         R->Prev = Result.Max;
37.         Result.Max->Next = R;
38.         R = R->Prev;
39.         }
40.         Result.Max = Result.Max->Prev;
41.     }
42.     Result.Max = R;
43.     R->Prev = NULL;
44.     //std::cout << 1;
45.     return Result;
46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top