C语言高手帮忙做个简单的题 啊

来源:百度知道 编辑:UC知道 时间:2024/09/25 23:18:25
实验要求:
有必要的类型说明,并完成下述函数功能:
CreateList( ):生成一个单链表
ListInsert( ):在单链表中插入一个元素
ListDelete( ):从单链表中删除一个元素
ListFindKeyword( ):按关键字查找一个元素
ListFindOrder( ):按序号查找一个元素
ListPrint( ):显示单链表所有元素

在主函数main中调用各个子函数完成单链表的基本操作。

#include <malloc.h>
#include <stdio.h>
#define NULL 0
#define LEN sizeof(struct student)
struct student
{
long num;
float score;
struct student *next;
};
int n;

struct student *creat(void)

{
struct student* head;
struct student *p1,*p2;
n = 0;
p1=p2=(struct student*)malloc(LEN);
scanf("%ld,%f",&p1->num,&p1->score);
// printf("%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;
return(head);
}
void print(struct student* head)
{
struct student *p;
printf("\nNow,These %d record are:&#