#include<stdio.h>
#include<stdlib.h>
typedef struct node
{
int num;
struct node *next;
}LN;
LN *Creat();
LN Divide(LN *h);
void Printf(LN *s);
void main()
{
LN *h;
h=Creat();
Divide(h);
printf("The even term is: ");
Printf(h);
printf("The odd term is: ");
Printf(q);
}
LN *Creat()
{
LN *p;
LN *b;
LN *h;
int a;
h=(LN *)malloc(sizeof(LN));
h->next=NULL;
b=h;
printf("Input the sum of the numbers: ");
scanf("%d",&a);
for(int i=0;i<a;i++)
{
printf("Input the %d number: ",i+1);
p=(LN *)malloc(sizeof(LN));
scanf("%d",&p->num);
b->next=p;
b=p;
}
p->next=NULL;
system("CLS");
return h;
}
LN Divide(LN *h)
{
LN *q;
LN *b;
q=(LN *)malloc(sizeof(LN));
b=q;
while(h!=NULL&&h->next!=NULL)
{
b=h->next;
h->next=b->next;
h=h->next;
}
return *q;
}
void Printf(LN *s)
{
LN *p;
p=s->next;
while(p)
{
printf("%d ",p->num);
p=p->next;
}
}
**在Divide这个函数里面我有两个链表,如代码所示,我已经返回头指针q,可是为什么程序还是运行不了?简而言之就是我的q怎么传出来,我明明已经传出来了,在主函数里面又要由什么接应他。
**