#include <stdio.h>
#include <malloc.h>
#define LEN sizeof(struct student)

struct student

...{
long num;
float score;
struct student *next;
};

struct student *listA,*listaB;
int n,sum=0;

struct student *creat(void)

...{
struct student *p1,*p2,*head;
n=0;
p1=p2=(struct student *)malloc(LEN);
printf(" ,please input student's number and score: ");
scanf("%ld %f",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)

...{
n=n+1;
if(n==1) head=p1;
else p2->next=p1;
p2=p1;
p1=(struct student *)malloc(LEN);
scanf("%ld %f",&p1->num,&p1->score);
}
p2->next=NULL;
sum=sum+n;
printf("There are %d members. %d/%d ",n,n,sum);
return(head);
}

struct student *link(struct student *headA,struct student *headB)

...{
struct student *p1,*p2;
p1=headA;
p2=headB;
while(p1->next)
p1=p1->next;
p1->next=headB;
return(headA);
}

main()

...{
struct student *headA,*headB,*linkhead;
struct student *creat(void);
struct student *link(struct student *,struct student *);
int i=0;
printf("The First list");
headA=creat();
printf("The second list");
headB=creat();
linkhead=link(headA,headB);
printf("The First list: ");
while(headA!=NULL)

...{
i=i+1;
printf("%02d:%ld, %g ",i,headA->num,headA->score);
headA=headA->next;
}
i=0;
printf("The second list: ");
while(headB!=NULL)

...{
i=i+1;
printf("%02d:%ld, %g ",i,headB->num,headB->score);
headB=headB->next;
}
printf("All member of listA and listB suce as: ");
i=0;
while(linkhead)

...{
i=i+1;
printf("%05d:%ld, %g ",i,linkhead->num,linkhead->score);
linkhead=linkhead->next;
}
printf("Member total:%d ",sum);
}


本程序在Microsoft Visual Studio C++6.0中通过编译、链接、执行。
--------------------Configuration: 11.8 - Win32 Debug--------------------
Compiling...
11.8.c
Linking...
11.8.exe - 0 error(s), 0 warning(s)
>>>>0警告,0错误。