-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLLIE.CPP
69 lines (65 loc) · 1.11 KB
/
LLIE.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<iostream.h>
#include<conio.h>
#include<process.h>
struct Node
{ int info;
Node *next;
} *start, *newptr, *save, *ptr,*rear;
Node *create_new_node(int);
void Insert_End(Node*);
void Display(Node*);
void main()
{ clrscr();
start=rear=NULL;
int inf;
char ch='y';
while(ch=='y'||ch=='Y')
{
clrscr();
cout<<"\n Enter info for new Node:- ";
cin>>inf;
cout<<"\n Creating new node!!! Press Enter to continue...";
getch();
newptr=create_new_node(inf);
if(newptr!=NULL)
{
cout<<"\n\nNew Node Created...";
getch();
}
else
{
cout<<"Cannot create new node.. Aborting";
getch();
exit(1);
}
cout<<"\nInserting in End of the list... \n";
Insert_End(newptr);
cout<<"\n\nNow the list is:- ";
Display(start);
cout<<"Enter y or Y to enter more.. N to exit..\n";
cin>>ch;
}
getch();
}
Node *create_new_node(int n)
{ ptr=new Node;
ptr->info=n;
ptr->next=NULL;
return ptr;
}
void Insert_End(Node* np)
{ if(start==NULL)
start=rear=np;
else
{
rear->next=np;
rear=np;
}
}
void Display(Node* np)
{ while(np!=NULL)
{ cout<<np->info<<"->";
np=np->next;
}
cout<<"!!!\n";
}