Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct node
- {
- int data;
- node* next;
- };
- node* Head=NULL;
- void print()
- {
- cout<<"Current Linked List : ";
- node* curr=Head;
- while(curr!=NULL)
- {
- cout<<curr->data<<" ->";
- curr=curr->next;
- }
- cout<<endl;
- }
- int main()
- {
- node* curr; //sudhu nia rakhla kisu assign korla na
- int value,n;
- cin>>n;
- cout<<endl;
- for(int i=0;i<n;i++)
- {
- cin>>value;
- node* nptr= new node;
- nptr->data=value;
- nptr->next=NULL;
- if(Head==NULL)
- {
- Head = nptr;
- curr = nptr;
- }
- else
- {
- curr->next=nptr;
- curr=nptr;
- }
- }
- print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement