Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<iostream>
- using namespace std;
- struct node
- {
- int data;
- struct node* link;
- };
- struct node* head;
- void print()
- {
- struct node* temp;
- temp=head;
- while(temp!=NULL)
- {
- printf("%d ",temp->data);
- temp=temp->link;
- }
- }
- void insert(int value)
- {
- struct node* temp=(struct node*)malloc(sizeof(struct node));
- temp->data=value;
- temp->link=NULL;
- if(head==NULL)
- {
- head=temp;
- }
- else
- { struct node* t;
- t=head;
- while(t->link!=NULL)
- {
- t=t->link;
- }
- t->link=temp;
- }
- }
- int main()
- {
- head=NULL;
- insert(6);
- insert(7);
- insert(5);
- insert(9);
- insert(10);
- insert(1);
- insert(3);
- insert(20);
- Print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement