CARVIEW |
Select Language
HTTP/2 200
date: Wed, 15 Oct 2025 01:45:09 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=62df5f66e2155a9970085bced33ebb94fdbda8b9a3b71a3190bc0ffb8664eebda%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22jt4vNEjlCeYb56w1vqpc6HXIzC6KVpM6%22%3B%7D; HttpOnly; Path=/
cf-ray: 98eba2a55be5f470-BLR
#include <iostream>#include <string>using namespace std;class List{private - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class List
- {
- private:
- struct Node
- {
- Node()
- {
- next_ = nullptr;
- item_ = 0;
- }
- Node* next_;
- int item_;
- };
- Node* head_;
- public:
- List();
- ~List();
- List operator+(int item);
- List operator+=(int item);
- friend ostream& operator << (ostream& out, const List& list);
- void removeLess();
- void removeMinimal();
- };
- List::List() : head_(nullptr) {};
- List::~List()
- {
- //while (head_)
- //{
- // Node* temp = head_;
- // head_ = head_->next_;
- // delete temp;
- //}
- }
- List List::operator+(int item)
- {
- if (head_ == nullptr)
- {
- head_ = new Node;
- head_->item_ = item;
- head_->next_ = nullptr;
- }
- else
- {
- Node* newNode = new Node;
- newNode->item_ = item;
- newNode->next_ = head_;
- head_ = newNode;
- }
- return *this;
- }
- List List::operator+=(int item)
- {
- if (head_ == nullptr)
- {
- head_ = new Node;
- head_->item_ = item;
- head_->next_ = nullptr;
- }
- else
- {
- Node* current = this->head_;
- while (current->next_ != nullptr)
- {
- current = current->next_;
- }
- current->next_ = new Node;
- current = current->next_;
- current->item_ = item;
- current->next_ = nullptr;
- }
- return *this;
- }
- ostream& operator <<(ostream& out, const List& list)
- {
- List::Node* temp = list.head_;
- while (temp != nullptr)
- {
- out << temp->item_ << endl;
- temp = temp->next_;
- }
- return out;
- }
- void List::removeLess()
- {
- if (head_ != nullptr)
- {
- Node* current = head_;
- Node* processed = head_->next_;
- while (processed != nullptr)
- {
- if (processed->item_ < current->item_)
- {
- current->next_ = processed->next_;
- delete processed;
- }
- else
- {
- current = processed;
- }
- processed = current->next_;
- }
- }
- else cout << endl << "List is empty!" << endl;
- }
- void List::removeMinimal()
- {
- if (head_ != nullptr)
- {
- Node* temp = head_;
- int min = temp->item_;
- while (temp != nullptr)
- {
- if (temp->item_ < min)
- {
- min = temp->item_;
- }
- temp = temp->next_;
- }
- temp = head_;
- while (temp != nullptr)
- {
- if (temp->item_ == min)
- {
- head_ = temp->next_;
- delete temp;
- temp = head_;
- }
- else break;
- }
- temp = head_;
- Node* tempNext = head_->next_;
- while (tempNext != nullptr)
- {
- if (tempNext->item_ == min)
- {
- temp->next_ = tempNext->next_;
- delete tempNext;
- tempNext = temp->next_;
- }
- else
- {
- temp = tempNext;
- tempNext = temp->next_;
- }
- }
- }
- else cout << "List is empty!";
- }
- int main()
- {
- List list;
- int value;
- for (int i = 0; i < 5; ++i)
- {
- cin >> value;
- list += value;
- }
- cout << endl << list << endl;
- //list.removeLess();
- //cout << endl << list << endl;
- list.removeMinimal();
- cout << endl << list << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐MAKE $9OO INSTANTLY D A⭐⭐
Java | 4 sec ago | 0.15 KB
-
📌 Instant BTC Profit Method ✅ Working 7
JavaScript | 8 sec ago | 0.25 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 9 sec ago | 0.15 KB
-
⭐⭐⭐ChangeNOW Exploit⭐⭐
Java | 9 sec ago | 0.15 KB
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 10 sec ago | 0.24 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 16 sec ago | 0.15 KB
-
✅ Make $2500 in 20 minutes⭐ 0
JavaScript | 16 sec ago | 0.25 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 19 sec ago | 0.24 KB
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. OK, I Understand