C语言问题求代码高手来解决啊

来源:百度知道 编辑:UC知道 时间:2024/05/21 03:42:37
建立一个动态连接表 连表中的每一结点包括
学号 姓名 性别 年龄 成绩。 程序能实现以下功能: 1建立链表 显示链表 查找链表中是否存在某个元素,并显示这个元素的所有信息,若没有这个元素则显示“无此记录”的信息 4删除链表中指定的学号的结点 5 在链表中指定的位置插入一个新结点
要求 陈滚运行中显示实现以上功能锁构成的菜单,然后根据选项调用相应程序及对影的结果然后在现实菜单结构 知道按’退出‘选项程序执行结束

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct student{
int id;
char name[30];
char gender;
int age;
float score;
struct student *next;
};

typedef struct student Student;

Student *s=0;

void add(int id,char name[],char gender,int age,float score){
if(s==0){
s=(Student *)malloc(sizeof(Student));
s->id=id;
strcpy(s->name,name);
s->gender=gender;
s->age=age;
s->score=score;
s->next=0;
}
else{
Student *p=s;
while(p->next!=0){
p=p->next;
}
Student *t=(Student *)malloc(sizeof(Student));
t->id=id;
strcpy(t->name,name);
t->gender=gender;
t->age=age;
t->score=score;
t->next=0;
p->next=t;
}
}

void display(){
Student *p=s;
while(p!=0){<