Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdafx.h>
- #include <stdio.h>
- #include <iostream>
- #include <malloc.h>
- struct list{
- int data;
- struct list * next;
- };
- int main(){
- struct list * first1 = NULL;
- struct list * first2 = NULL;
- for (int i = 0; i < 100; i++){
- struct list * p1 = (struct list *) malloc (sizeof(struct list));
- p1->data = i;
- p1->next = NULL;
- if (first1 == NULL) first1 = p1;
- else {
- struct list * cur = first1;
- while (cur->next!= NULL) cur = cur->next;
- cur->next = p1;
- }
- }
- for (int i = 0; i < 30; i++){
- struct list * p2 = (struct list *) malloc (sizeof(struct list));
- p2->data = i;
- p2->next = NULL;
- if (first2 == NULL) first2 = p2;
- else {
- struct list * cur = first2;
- while (cur->next != NULL) cur = cur->next;
- cur->next = p2;
- }
- }
- struct list * cur = first1;
- struct list * cur1 = first1;
- while (cur->next != NULL) cur = cur->next;
- cur->next = first2;
- while (cur1 != NULL){
- std::cout<<cur1->data<<" ";
- cur1 = cur1->next;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement