Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- class Album {
- struct Node
- {
- int a;
- Node *next;
- };
- Node *head = nullptr;
- public:
- int size = 0;
- friend void operator +=(Album& obj1, int element)
- {
- Node *current = new Node;
- current->a = element;
- current->next = obj1.head;
- obj1.head = current;
- obj1.size++;
- }
- friend ostream& operator << (ostream &out, Album obj1)
- {
- while (obj1.head != NULL)
- {
- cout << obj1.head->a << endl;
- obj1.head = obj1.head->next;
- }
- cout << "Количество эллементов - " << obj1.size << endl;
- return out;
- }
- friend bool operator ==(Album obj1,Album obj2)
- {
- if (obj1.size != obj2.size)
- return false;
- while (obj1.head !=NULL)
- {
- if (obj1.head->a != obj2.head->a)
- return false;
- obj1.head = obj1.head->next;
- obj2.head = obj2.head->next;
- }
- return true;
- }
- Album sort(Album obj1)
- {
- }
- };
- int main()
- {
- setlocale(LC_ALL, "ru");
- Album obj1;
- Album obj2;
- int c;
- cin >> c;
- for (int i = 0; i < c; i++)
- {
- obj1 += rand();
- obj2 += rand() % 22;
- }
- cout << obj1;
- cout << endl;
- cout << obj2;
- if (obj1 == obj2)
- cout << "списки равны" << endl;
- else
- {
- cout << "списки неравны" << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement