//编程重头戏--------第八章习题十
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#define LEN sizeof(struct student)
int n;
//int b[100];
//float a[100];
int i = 0;
struct student {
int num;
float score;
struct student* next;
};
struct student* creat() {
struct student* head, * p1, * p2;
n = 0;
p1 = p2 = (struct student*)malloc(LEN);
head = NULL;
scanf("%d%f", &p1->num, &p1->score);
b[i] = p1->num;
a[i] = p1->score;
i = 1;
while (p1->num != 0) {
n = n + 1;
if (n == 1)
head = p1;
else
p2->next = p1;
p2 = p1;
p1 = (struct student*)malloc(LEN);
scanf("%d%f", &p1->num, &p1->score);
b[i] = p1->num;
a[i] = p1->score;
i = i + 1;
}
p2->next = NULL;
return head;
}
void print(struct student* head) {
struct student* p;
p = head;
if (p != NULL) {
do {
C语言(第五版)---------第九章---------链表,结构体
最新推荐文章于 2024-08-14 07:21:13 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)