怎样建立一个链表操作题(包括建立,插入,删除,打印等)?

来源:百度知道 编辑:UC知道 时间:2024/09/20 07:01:02
请给出一个完整的C语言代码

太复杂了

这是我曾经的一个作业题,我做得不好,但还凑合,希望能帮你一点忙
#include<stdio.h>
#include<alloc.h>
#define LEN sizeof(struct student)
struct student
{
long num;
char nam[20];
char cla[10];
int s[5];
struct student *next;
}*head=NULL;
void new()
{
struct student *head,*p;
insert();
}

insert()
{
struct student *p;
char c;
int i;
p=(struct student *)malloc(LEN);
printf("\nNO.:");
scanf("%ld",&p->num);
printf("\nname:");
scanf("%s",&p->nam);
printf("\nclass:");
scanf("%s",&p->cla);
printf("Input scores:maths english physics art P.E\n");
for(i=0;i<5;i++)
scanf("%d",&p->s[i]);
p->next=head;
head=p;
printf("\nDo you continue to insert Y or N\n");
fflu