Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using std::cin;
- using std::cout;
- struct Node {
- int data;
- Node *next;
- };
- Node* create(int _data) {
- Node *t = new Node();
- t->data = _data;
- t->next = nullptr;
- return t;
- }
- void add_back(Node *&root, Node *added) {
- root->next = added;
- }
- #include "func.h"
- int main() {
- int n; cin >> n;
- int a; cin >> a;
- Node *root = create(a), *last;
- last = root;
- for (int i = 0; i < n - 1; ++i) {
- cin >> a;
- Node *t = create(a);
- add_back(last, t);
- last = t;
- }
- print(root);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement