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