Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- #include<conio.h>
- #include<stdio.h>
- #include<process.h>
- struct ticket
- {
- int tno;
- char pname[25];
- ticket *node;
- };
- ticket *temp=NULL;
- ticket *front=NULL;
- ticket *rear=NULL;
- void input();
- void Delete();
- void show();
- void main()
- {
- clrscr();
- int ch;
- char c;
- do
- {
- cout<<"\n\n\t\t\tQUEUE MENU\n\tEnter\n";
- cout<<"\t1.Input\n\t2.Delete\n\t3.Display\n\t4.Exit";
- cout<<"\n\n\tENTER YOUR CHOICE:\t";
- cin>>ch;
- switch(ch)
- {
- case 1:
- do
- {
- clrscr();
- input();
- cout<<"\n\n\t\tData Entered\n";
- cout<<"\n\n Enter More Values (Y/N): ";
- cin>>c;
- }while(c=='y'||c=='Y');
- break;
- case 2:
- clrscr();
- cout<<"\n\t\tDeleted Data:\n\n" ;
- Delete();
- break;
- case 3:
- clrscr();
- cout<<"\n\t\t Queue:\n\n";
- show();
- break;
- case 4:
- exit(0);
- break;
- default:
- cout<<"\n\t\tWRONG CHOICE\n\n\t\tENTER AGAIN\n\n";
- }
- }while(ch!=4);
- }
- void input()
- {
- temp=new ticket;
- if(temp==NULL)
- cout<<"\n MEMORY FULL\n";
- else
- {
- cout<<"\n Enter Ticket Number: ";
- cin>>temp->tno;
- cout<<"\n Enter Passenger Name: ";
- gets(temp->pname);
- temp->node=NULL;
- if(front==NULL)
- {
- front=temp;
- rear=temp;
- }
- else
- {
- rear->node=temp;
- rear=temp;
- }
- }
- }
- void Delete()
- {
- if(front==NULL)
- cout<<"\n\t\tQUEUE EMPTY\n";
- else
- {
- temp=front;
- cout<<"\n Ticket number: "<<temp->tno;
- cout<<"\n Passenger name: ";
- puts(temp->pname);
- front=front->node;
- delete temp;
- }
- }
- void show()
- {
- if(front==NULL)
- cout<<"\n\t\tQUEUE EMPTY\n";
- else
- {
- temp=front;
- while(temp!=NULL)
- {
- cout<<"\n\t"<<temp->tno<<"\t\t";
- puts(temp->pname);
- temp=temp->node;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement