#include"m_list.h"
void main()
{
list *first=NULL,*second=NULL,*third=NULL;
int choice,i;
char ch='y';
while(1)
{
clrscr();
printf("case 1: Create list");
printf("case 2: Add in the list");
printf("case 3: Delete in the list");
printf("case 4: Append two list");
printf("case 5: show list");
printf("case 6: Exit");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: //create list
while(ch!='n')
{
printf("Enter element : ");
scanf("%d",&i);
create(&first,i);
printf("Enter element (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
}
break;
case 2: //add in the list
int c;
clrscr();
printf("case 1: Add in Beginning");
printf("case 2: Add in End");
printf("case 3: Add After a given element");
printf("case 4: Return to main menu");
printf("Enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1: add_at_beg(&first);
break;
case 2: add_at_end(&first);
break;
case 3: add_after_given_element(&first);
break;
case 4: break;
}
break;
case 3:
clrscr();
printf("case 1: Delete in Beginning");
printf("case 2: Delete in End");
printf("case 3: Delete a specified element");
printf("case 4: Return to main menu");
printf("Enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1: del_at_beg(&first);
break;
case 2: del_at_end(&first);
break;
case 3: del_specified_element(&first);
break;
case 4: break;
}
break;
case 4:
char ch='y';
printf("Enter element in second list : ");
while(ch!='n')
{
printf("Enter element : ");
scanf("%d",&i);
create(&second,i);
printf("Enter element (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
}
append(&third,first,second);
break;
case 5: //show list
clrscr();
printf("case 1: List 1");
printf("case 2: List 2");
printf("case 3: List 3");
printf("Enter choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: show(first);break;
case 2: show(second);break;
case 3: show(third);break;
}
break;
case 6: exit(0);
}
}
}
void main()
{
list *first=NULL,*second=NULL,*third=NULL;
int choice,i;
char ch='y';
while(1)
{
clrscr();
printf("case 1: Create list");
printf("case 2: Add in the list");
printf("case 3: Delete in the list");
printf("case 4: Append two list");
printf("case 5: show list");
printf("case 6: Exit");
printf("Enter your choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: //create list
while(ch!='n')
{
printf("Enter element : ");
scanf("%d",&i);
create(&first,i);
printf("Enter element (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
}
break;
case 2: //add in the list
int c;
clrscr();
printf("case 1: Add in Beginning");
printf("case 2: Add in End");
printf("case 3: Add After a given element");
printf("case 4: Return to main menu");
printf("Enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1: add_at_beg(&first);
break;
case 2: add_at_end(&first);
break;
case 3: add_after_given_element(&first);
break;
case 4: break;
}
break;
case 3:
clrscr();
printf("case 1: Delete in Beginning");
printf("case 2: Delete in End");
printf("case 3: Delete a specified element");
printf("case 4: Return to main menu");
printf("Enter your choice : ");
scanf("%d",&c);
switch(c)
{
case 1: del_at_beg(&first);
break;
case 2: del_at_end(&first);
break;
case 3: del_specified_element(&first);
break;
case 4: break;
}
break;
case 4:
char ch='y';
printf("Enter element in second list : ");
while(ch!='n')
{
printf("Enter element : ");
scanf("%d",&i);
create(&second,i);
printf("Enter element (y/n) : ");
fflush(stdin);
scanf("%c",&ch);
}
append(&third,first,second);
break;
case 5: //show list
clrscr();
printf("case 1: List 1");
printf("case 2: List 2");
printf("case 3: List 3");
printf("Enter choice : ");
scanf("%d",&choice);
switch(choice)
{
case 1: show(first);break;
case 2: show(second);break;
case 3: show(third);break;
}
break;
case 6: exit(0);
}
}
}
No comments:
Post a Comment