#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
定义一个student结构体,并将其定义别名为stu
typedef struct student
{
char xuehao[200];
char xingming[10];
char xingbie[5];
int nianling;
char zhuanye[20];
char dizhi[200];
int shengri;
int chengji;
struct student *next;
}stu;
void chuangjian(stu*head);
void xiugai(stu*head);
void baocun(stu*head);
void charu(stu*head);
void chaxun(stu*head);
void PaiMingBiao(stu *head);
void paixv(stu *head);
void xianshi(stu*head);
void xiugai(stu*head);
void duqu(stu *head);
创建新生信息(添加学生信息)
void chuangjian(stu *head)
{
system ("cls");
//清屏函数
stu *p;
p=head;
//申请动态空间给p1
stu *p1=(student*)malloc(sizeof(student));
//向p1中存入数据
printf("请输入学号:\n");
scanf("%s",&p1->xuehao);
printf("请输入姓名;\n");
scanf("%s",&p1->xingming);
printf("年龄:\n");
scanf("%d",&p1->nianling);
printf("请输入性别:\n");
scanf("%s",&p1->xingbie);
printf("请输入专业:\n");
scanf("%s",&p1->zhuanye);
printf("请输入入学英语成绩:\n");
scanf("%d",&p1->chengji);
printf("请输入家庭地址:\n");
scanf("%s",&p1->dizhi);
printf("请输入生日:\n");
scanf("%d",&p1->shengri);
while(p->next!=NULL)
//若为首条存入信息,此时p->next=NULL,故不进入第二个while循
//环,连接head与p1,p1->next=NULL,显示“添加成功!”
{
while(strcmp(p->next->xuehao,p1->xuehao)==0)
{
//添加信息时比较学号是否相同,此时p->next!=NULL,进入第二个
//while循环,若p->next内容与p1内容一致,则会输出“已存在”,
//在期间内,p不断向后移动,直到p-next==NULL时,与p1连接(p1的
//插入使用的是尾插法)
printf("该学生已存在!\n");
return;
}
p=p->next;
}
p->next=p1;
p1->next=NULL;
printf("添加成功!\n");
}
修改学生信息
//首先需明白,在进行此环节时,程序中已经存在一段链表
void xiugai(stu*head)
{
system ("cls");
//定义指针p指向头结点的下一个节点
stu*p=head->next;
char xuehao[200];
printf("请输入你想修改的学生的学号\n");
scanf("%s",xuehao);
while(p!=NULL)
//p一直向后移动直到节点中的学号与输入的一致,停止,修改
{
if(strcmp(xuehao,p->xuehao)==0)
{