#include
#include
#include
#include
#include
struct node{
int data;
struct node *link;
};
struct node *cur,*first,*last;
int create();
int insert();
int delte();
int display();
int create()
{
printf("\nENTER THE FIRST ELEMENT: ");
cur=(struct node *)malloc(sizeof(struct node));
scanf("%d",&cur->data);
cur->link=NULL;
first=cur;
last=cur;
}
int insert()
{
printf("\nENTER THE NEXT ELEMENT: ");
cur=(struct node *)malloc(sizeof(struct node));
scanf("%d",&cur->data);
cur->link=NULL;
last->link=cur;
last=cur;
}
int delte()
{
if(first==NULL)
{
printf("\t\nQUEUE IS EMPTY\n");
}
else
{
cur=first;
first=first->link;
cur->link=NULL;
printf("\n DELETED ELEMENT IS %d\n",cur->data);
free(cur);
}
}
int display()
{
cur=first;
printf("\n");
while(cur!=NULL)
{
printf("\t%d",cur->data);
cur=cur->link;
}
}
int main()
{
int ch;
while(1)
{
printf("\nPROGRAM QUEUE LINKED LIST\n");
printf("\n 1. CREATE \n 2. INSERT \n 3. DELETE \n 4. DISPLAY \n 5. EXIT \n");
printf("\nENTER YOUR CHOICE : ");
scanf("%d",&ch);
system("cls");
switch(ch)
{
case 1:
create();
display();
cout<
0 komentar:
Posting Komentar