Created
September 2, 2025 19:38
-
-
Save l3ngli/51a26f92a0f6a910084b1e6db2421339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| using namespace std; | |
| class Node { | |
| public: | |
| int value; | |
| Node* next; | |
| Node(int value) { | |
| this->value = value; | |
| this->next = nullptr; | |
| } | |
| }; | |
| int main() | |
| { | |
| Node* head = nullptr; | |
| Node* tail = nullptr; | |
| Node* current = new Node(1); | |
| head = current; | |
| tail = current; | |
| current = new Node(2); | |
| current->next = head; | |
| head = current; | |
| current = new Node(3); | |
| current->next = head; | |
| head = current; | |
| cout << head->value; | |
| cout << head->next->value; | |
| cout << head->next->next->value; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment