链表问题!!!
#include "stdio.h"#include "malloc.h"
typedef struct node
{
int data;
struct node *next;
}NODE;
NODE *create();
void Link(NODE *head1,NODE *head2);
//void print(NODE *head);
main()
{
NODE *a,*b,*head1,*head2,*p;
printf("Please enter the first element of a linked list :");
a=create();
head1=a;
p=a;
printf("Please enter the second element of list:");
b=create();
head2=b;
printf("List merger, please wait ...");
Link(a,b);
p=p->next;
printf("The output list as follows:");
while(p->next!=head1)
{
printf("%3d",p->data);
p=p->next;
}
}
NODE *create()
{
NODE *head,*p,*q;
int a;
char ch;
head=(NODE*)malloc(sizeof(NODE));
q=head;
ch='*';
printf("input the list:");
while(ch!='?')
{
scanf("%d",&a);
p=(NODE*)malloc(sizeof(NODE));
p->data=a;
q->next=p;
q=p;
ch=getchar();
}
p->next=head;
return(head);
}
void Link(NODE *head1,NODE *head2)
{
NODE *p1,*p2;
p1=head1;
p2=head2;
while(p2->next!=head2) //第二个链表末尾链接到第一个链表的头
p2=p2->next;
p2->next=head1;
while(p1->next=head1) ////第一个链表末尾链接到第二个链表的头
p1=p1->next;
p1->next=head2;
}
/*void print(NODE *head)
{
NODE *p1,p2;
p*/
帮我看一下呀,“Link(a,b);”运行到这里就不能运行了,呵呵,先谢谢你了