求助求助,前辈请进
#include<iostream>using namespace std;
#include<iomanip>
typedef struct LNode
{
int data;
struct LNode *next;
}LinkList;
void CreateList(LinkList *&L,int a[],int n)
{
LinkList *s;int i;
L=(LinkList *)malloc(sizeof(LinkList));
L->next=NULL;
for(i=0;i<n;i++)
{ s=(LinkList *)malloc(sizeof(LinkList));
s->data=a[i];
s->next=L->next;
L->next=s;
}
}
void DispList(LinkList *L)
{ LinkList *p=L->next;
while(p!=NULL);
{ cout<<p->data;
p=p->next;
}
cout<<endl;
}
void splist(LinkList *&L,LinkList *&L1,LinkList *&L2)
{ LinkList *p=L->next,*q,*r1;
L1=L;
r1=L1;
L2=(LinkList *)malloc(sizeof(LinkList));
L2->next=NULL;
while(p!=NULL)
{ q=p->next;
r1->next=p;
r1=p;
p=q->next;
q->next=L2->next;
L2->next=q;
}
r1->next=NULL;
}
int main( )
{
int a[10]={1,-1,2,-2,3,-3,4,-4,5,-5};
LinkList * L,* L1,* L2;
CreateList(L,a,10);
DispList(L);
cout<<endl;
splist(L,L1,L2);
DispList(L1);
cout<<endl;
DispList(L2);
cout<<endl;
return 0;
}
没有错误,但运行结果没显示,求教!!!!!!