#include <stdio.h>
#include <stdlib.h>
#define LEN sizeof(struct student)
struct student
{
long num;
int score;
struct student *next;
};
struct student lista,listb;
int n,sum=0;
int main()
{
struct student *creat(void);
struct student *insert(struct student*,struct student*);
void print(struct student*);
struct student *ahead,*bhead,*abh;
printf("input list a:\n");
ahead=creat();
sum=sum+n;
printf("input list b:\n");
bhead=creat();
sum=sum+n;
abh=insert(ahead,bhead);
print(abh);
return 0;
}
struct student *creat(void)
{
struct student *p1,*p2,*head;
n=0;
p1=p2=(struct student*)malloc(sizeof(LEN));
printf("input number & scores of student:\n");
printf("if number is 0,stop inputing.\n");
scanf("%ld,%ld",&p1->num,&p1->score);
head=NULL;
while(p1->num!=0)
{
某强书上习题:合并链表
最新推荐文章于 2022-06-06 23:45:00 发布
本文详细探讨了如何合并两个已排序的链表,通过递归和迭代两种方式实现,并对比了它们的时间复杂度和空间复杂度。同时,对链表数据结构的基础知识进行了回顾,适合初学者和进阶者巩固链表操作技巧。
摘要由CSDN通过智能技术生成