السلام عليكــم ورحمـة الله وبركاتـه
رجاءا انا بدي اكمل باقى الاوامر ارجواالمساعده وارجوا اكتشاف شو الخطا
هادا البرنامج
#include<string>
#include<iostream>
#include<conio.h>
using namespace ::std;
struct node
{
int number;
node *next;
};
typedef node *node_ptr; // to use program easily
// prototype functions
//*********************************************************************
node_ptr make_new_node(node_ptr &first,int x);
void display_list(node_ptr first );
void create_nodes(node_ptr &first,int n);
void order_insert(node_ptr &first,int x);
void insert_begin(node_ptr &first);
void insert_last(node_ptr &first);
void delete_first(node_ptr &first);
void delete_last(node_ptr &first);
int count_alist(void);
void sortALL(void);
void invert(void);
void concatenate(void);
//************************************************************************
void main() {
//declarations
//************
node_ptr first;
first=NULL;
char choose;
int n;
cout<<"*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=\n"
<<"\t* >>>NAME: *\n"
<<"\t* *\n"
<<"\t* >> *\n"
<<"\t* *\n"
<<"\t* >> *\n"
<<"\t\t\n*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n";
done:
cout<<"\n\n\t\t WHAT DO YOU WANT TO DO ??\n\n"
<<"\t*******************************************\n"
<<"\t*\t 1- create alist *\n"
<<"\t*\t 2- display list *\n"
<<"\t*\t 3- insert_first *\n"
<<"\t*\t 4- insert_position *\n"
<<"\t*\t 5- insert_end *\n"
<<"\t*\t 6- delete_first *\n"
<<"\t*\t 7- delete_position *\n"
<<"\t*\t 8- delete_end *\n"
<<"\t*\t 9- count alist *\n"
<<"\t*\t 10- sort alist *\n"
<<"\t*\t 11_concaterate list *\n"
<<"\t*\t 12- exit from application *\n"
<<"\t*******************************************\n";
cin>>choose;
switch(choose) {
case'1':
cout<<"\t Enter numbre of nodes to create\n";
cin>>n;
create_nodes(first,n);
goto done;
break;
case'2':
display_list(first);
goto done;
break;
case'3':
insert_begin(first);
goto done;
break;
case'4':
insert_last(first);
goto done;
break;
case'5':
delete_begin(first);
goto done;
break ;
case'6':
delete_last(first);
goto done;
break ;
case'7':
count_last;
goto done;
break;
case'8':
sort- nodes(List);
goto done;
break;
case'9':
concaterate_nodes(List);
goto done;
break;
default:
char continuo;
retry:
cout<<"are you sure you want to exit (y / n )\n";
cin>> continuo;
if(continuo=='n')
{
goto done;
}
else if(continuo=='y')
{
}
else
{
cout<<"you are not press acorrect botton,please Retry do\n";
goto retry;
}
break;
}
}
// functions
//-------------------
// TO MAKE anew node
//*********************
node_ptr make_new_node(int x)
{
node_ptr p;
p=new node;
p->number =x;
p->next =NULL;
return p;
}
// TO display anodes
// **********************
void display_list(node_ptr first )
{
node_ptr p;
if(first==NULL)
cout<<"NO, nodes founds>>>";
else
{
cout<<"\t The Data in the nodes are :\n";
p=first;
while(p!=NULL)
{
cout<<"value of node ---> ";
cout<<p->number <<endl;
p=p->next;
}
}
// TO CREATE lists of nodes
// ****************************
void create_nodes(node_ptr &first,int n)
{
int x;
cout<<"\t\t enter the data in nodes\n";
for(int i=1;i<=n;i++)
{
cout<<" node # "<<i<<endl;
cin>>x;
order_insert(first,x);
}
}
// Order insert
//*********************************
void order_insert(node_ptr &first,int x)
{
node_ptr p;
if(first==NULL)
{
first=make_new_node (x);
}
else if(x==first->number )
{
cout<<"\t This value in node is Exist \n";
}
else if(x<first->number )
{
p=make_new_node (x);
p->next =first;
first=p;
}
else
order_insert(first->next ,x);
}
// Insert in the Begining
// **************************
void insert_begin(node_ptr &first)
{
int x;
cout<<"enter value in new node\n";
cin>>x;
node_ptr p;
p=make_new_node(x);
p->next=first;
first=p;
}
// Insert in the last
// ************************
void insert_last(node_ptr &first)
{
int x;
cout<<"entr value in new node \n";
cin>>x;
node_ptr p,q;
if(first==NULL)
{
first=make_new_node (x);
}
else
{
p=first;
while(p->next!=NULL)
{
p=p->next ;
}
q=make_new_node (x);
p->next =q;
}
}
// TO delete first node
// ******************************************
void delete_first(node_ptr &first)
{
if(first==NULL)
{
cout<<"NO,nodes found .....\n";
}
else
{
node_ptr p;
p=first;
first=first->next;
delete p;
}
}
// TO delete last
// *****************
void delete_last (node_ptr &first)
{
if(first==NULL)
cout<<" NO;nodes found......\n";
else if (first->next ==NULL)
delete first;
else
delete_last (first->next );
getchar();
};