1、 建立一个动态链表,链表中每一结点包括:学号、姓名、性别、年龄、成绩。程序能实现以下功能:
建立链表
显示链表
查找链表中是否存在某个元素,并显示这个元素的所有信息,若没有这个元素则显示“无此记录!”的信息。
删除链表中指定学号的结点。
在链表中指定的位置插入一个新结点(学号不能和其他结点重复)。
要求:程序运行中,先显示实现以上功能所构成的菜单,然后根据选项调用相应程序及显示其对应的结果,然后再显示菜单程序,直到按“退出”选项,程序执行结束。
完整的代码如下:
#include "stdio.h"#include "stdlib.h"typedef struct student{
int id; //学号 char name[20]; //姓名 char sex; //性别(f或m) int age; //年龄 int score; //成绩 struct student *next;}student;student *head=NULL;int length; //链表的长度void create(){ student *p1,*p2; length=0; p1=(student *)malloc(sizeof(student)); p1->id=-1; if(head==NULL) head=p1; printf("请输入学生的学号、姓名、性别、年龄、成绩信息:\n"); while(1) //学号为0的时候退出 { p2=(student