主题:请教
#include <iostream>
using namespace std;
typedef struct node{
int data;
struct node *next;
}Lnode,*Linklist;
Linklist insert(Linklist l,int x);
int main()
{int i,j;
Linklist A;
cout<<"enter the number:\n";
cin>>i;
cout<<"enter:\n";
A=A->next;
for(j=0;j<i;j++)
{cin>>A->data;
A=A->next;}
A->next=NULL;
A=insert(A,6);
while(A!=NULL)
{cout<<A->data;
A=A->next;}
cout<<endl;
delete []A;
return 0;
}
Linklist insert(Linklist l,int x)
{ Lnode *p,*s;
p=l;
while(p->next&&x>p->next->data)
p=p->next;
s=new Lnode;
s->data=x;
s->next=p->next;
p->next=s;
return l;
}为啥不能运行?
using namespace std;
typedef struct node{
int data;
struct node *next;
}Lnode,*Linklist;
Linklist insert(Linklist l,int x);
int main()
{int i,j;
Linklist A;
cout<<"enter the number:\n";
cin>>i;
cout<<"enter:\n";
A=A->next;
for(j=0;j<i;j++)
{cin>>A->data;
A=A->next;}
A->next=NULL;
A=insert(A,6);
while(A!=NULL)
{cout<<A->data;
A=A->next;}
cout<<endl;
delete []A;
return 0;
}
Linklist insert(Linklist l,int x)
{ Lnode *p,*s;
p=l;
while(p->next&&x>p->next->data)
p=p->next;
s=new Lnode;
s->data=x;
s->next=p->next;
p->next=s;
return l;
}为啥不能运行?