Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct ll {
- int value;
- ll* next;
- };
- ll* root = NULL;
- ll* root1 = NULL;
- ll* root2 = NULL;
- ll* current = NULL;
- ll* tmp;
- void insert(ll* lroot, int value){
- if (lroot == NULL){
- lroot = new ll;
- lroot->value = value;
- lroot->next = NULL;
- current = lroot;
- return;
- }
- tmp = new ll;
- tmp->value = value;
- tmp->next = NULL;
- current->next = tmp;
- current = tmp;
- return;
- }
- void print(ll* lroot){
- current = lroot;
- while (current != NULL) {
- cout << current->value << " -> ";
- current = current->next;
- }
- cout << "NULL\n";
- return;
- }
- void readll(ll* lroot){
- int value;
- while (1) {
- cin >> value;
- if (!value) break;
- insert(lroot, value);
- }
- print(lroot);
- return;
- }
- int main() {
- readll(root1);
- readll(root2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement