/* 已有a、b两个链表,每个链表中的结点包括学号、成绩。要求把两个链表合并,按学号升序排列。 */
#include <stdio.h>
#include <stdlib.h>
typedef struct student{//链表结点
int ID;
int score;
struct student *next;//前指向
struct student *back;//后指向
} Stu;
typedef struct _list{
struct student *head1;//表头指针
struct student *tail1;//表尾指针
struct student *head2;
struct student *tail2;
} List;
void creat_a_link(List *pList, int N);//创建a链表
void creat_b_link(List *pList, int N);//创建b链表
void connect_link(List *paList);//链接链表
void sort_link(List *paList);//排序链表
int main(){
List list;
list.head1 = list.tail1 = list.head2=list.tail2=NULL;
int N, M;
scanf("%d%d", &N, &M);//属于A/B两个链表元素的数量;
creat_a_link(&list, N);
creat_b_link(&list, M);
connect_link(&list);
sort_link(&list);
return 0;
}
/* 创建a链表 */
void creat_a_link(List *pList, int N){
int num, score;
if(!N){
printf("can not creat empty list\n");
}
Stu *p
已有a、b两个链表,每个链表中的结点包括学号、成绩。要求把两个链表合并,按学号升序排列。
最新推荐文章于 2021-12-30 23:52:09 发布