|
|
|
@ -1,47 +1,49 @@
|
|
|
|
|
//****************************************头文件声明********************************************
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <conio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
//定义一个学生
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
//**********************************************************************************************
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
char num[12]; // 学号
|
|
|
|
|
char name[20]; // 姓名
|
|
|
|
|
char sex[4]; // 性别
|
|
|
|
|
int age; // 年龄
|
|
|
|
|
char birth[20]; // 生日
|
|
|
|
|
char home[100]; // 住址
|
|
|
|
|
char tel[15]; // 电话
|
|
|
|
|
char num[12]; // 学号
|
|
|
|
|
char name[20]; // 姓名
|
|
|
|
|
char sex[4]; // 性别
|
|
|
|
|
int age; // 年龄
|
|
|
|
|
char birth[20]; // 生日
|
|
|
|
|
char home[100]; // 住址
|
|
|
|
|
char tel[15]; // 电话
|
|
|
|
|
}student;
|
|
|
|
|
//节点
|
|
|
|
|
typedef struct Node
|
|
|
|
|
|
|
|
|
|
typedef struct Node //节点
|
|
|
|
|
{
|
|
|
|
|
student stu;//学生信息
|
|
|
|
|
struct Node* pnext;//指向下一个节点的指针
|
|
|
|
|
student stu; //学生信息
|
|
|
|
|
struct Node* pnext;//指向下一个节点的指针
|
|
|
|
|
}node;
|
|
|
|
|
node* phead=NULL; //头节点(空链表)
|
|
|
|
|
node* phead=NULL; //头节点(空链表)
|
|
|
|
|
|
|
|
|
|
//****************************************函数的声明********************************************
|
|
|
|
|
void Inputstudent(); //录入学生信息
|
|
|
|
|
void Printstudent(); //打印学生信息
|
|
|
|
|
void Savestudent(); //保存学生信息
|
|
|
|
|
void Lookstudent(); //查找学生信息
|
|
|
|
|
void Modifystudent(); //修改学生信息
|
|
|
|
|
void Readstudent(); //读取学生信息
|
|
|
|
|
void Deletestudent(); //删除学生信息
|
|
|
|
|
void yanshi(char *p); //延时函数说明
|
|
|
|
|
//**********************************************************************************************
|
|
|
|
|
|
|
|
|
|
//录入学生信息
|
|
|
|
|
void Inputstudent();
|
|
|
|
|
//打印学生信息
|
|
|
|
|
void Printstudent();
|
|
|
|
|
//保存学生信息
|
|
|
|
|
void Savestudent();
|
|
|
|
|
//查找学生信息
|
|
|
|
|
void Lookstudent();
|
|
|
|
|
//修改学生信息
|
|
|
|
|
void Modifystudent();
|
|
|
|
|
//读取学生信息
|
|
|
|
|
void Readstudent();
|
|
|
|
|
//删除学生信息
|
|
|
|
|
void Deletestudent();
|
|
|
|
|
int count=0;
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
while(1)
|
|
|
|
|
{ system("color 2A");
|
|
|
|
|
{
|
|
|
|
|
yanshi("\n\n\n\t\t**************************欢迎使用学生信息管理系统*****************\n");
|
|
|
|
|
system("cls");
|
|
|
|
|
while(1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
system("color 2A"); //调节控制台的背景和字体颜色
|
|
|
|
|
printf("\t\t\t*****************************************************************\n");
|
|
|
|
|
printf("\t\t\t|\t\t欢迎使用湖南工业大学学生信息管理系统\t\t|\n");
|
|
|
|
|
printf("\t\t\t*****************************************************************\n");
|
|
|
|
@ -56,73 +58,60 @@ int main()
|
|
|
|
|
printf("\t\t\t|\t\t\t7.删除学生信息\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t\t|\t\t\t0.退出系统\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t\t*****************************************************************\n");
|
|
|
|
|
printf("请输入:\n\n");
|
|
|
|
|
char ch=getch();//从键盘输入一个字符
|
|
|
|
|
switch(ch)
|
|
|
|
|
printf("请输入您的选择:\n\n");
|
|
|
|
|
char ch=getch(); //从键盘输入一个字符
|
|
|
|
|
switch(ch) //根据选择,调用不同的函数来完成不同的任务
|
|
|
|
|
{
|
|
|
|
|
case '1'://录入学生信息
|
|
|
|
|
Inputstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '2'://打印学生信息
|
|
|
|
|
Printstudent();
|
|
|
|
|
case '1': //录入学生信息
|
|
|
|
|
Inputstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '3'://保存学生信息
|
|
|
|
|
Savestudent();
|
|
|
|
|
case '2': //打印学生信息
|
|
|
|
|
Printstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '4'://读取学生信息
|
|
|
|
|
Readstudent();
|
|
|
|
|
case '3': //保存学生信息
|
|
|
|
|
Savestudent();
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '5'://查找学生信息
|
|
|
|
|
Lookstudent();
|
|
|
|
|
case '4': //读取学生信息
|
|
|
|
|
Readstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '5': //查找学生信息
|
|
|
|
|
Lookstudent();
|
|
|
|
|
break;
|
|
|
|
|
case '6'://修改学生信息
|
|
|
|
|
Modifystudent();
|
|
|
|
|
case '6': //修改学生信息
|
|
|
|
|
Modifystudent();
|
|
|
|
|
break;
|
|
|
|
|
case '7'://删除学生信息
|
|
|
|
|
Deletestudent();
|
|
|
|
|
case '7': //删除学生信息
|
|
|
|
|
Deletestudent();
|
|
|
|
|
break;
|
|
|
|
|
case '0'://退出系统
|
|
|
|
|
printf("ByeBye 欢迎再次使用!\n\n");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("您输入有误,请重新输入!\n\n");
|
|
|
|
|
case '0': //退出系统
|
|
|
|
|
system("cls");
|
|
|
|
|
yanshi("\n\n\n\n\n\t\t\t\tByeBye 欢迎再次使用!\n\n");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
printf("您输入有误,请重新输入!\n\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
system("pause"); //程序暂停
|
|
|
|
|
system("cls"); //清屏语句
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
//录入学生信息
|
|
|
|
|
void Inputstudent()
|
|
|
|
|
|
|
|
|
|
void Inputstudent() //录入学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 6F");
|
|
|
|
|
//创建一个节点来存储新的学生
|
|
|
|
|
node* pnewnode=(node*)malloc(sizeof(node));
|
|
|
|
|
system("cls"); //清屏语句
|
|
|
|
|
system("color 6F"); //清屏语句
|
|
|
|
|
node* pnewnode=(node*)malloc(sizeof(node)); //创建一个节点来存储新的学生
|
|
|
|
|
pnewnode->pnext=NULL;
|
|
|
|
|
|
|
|
|
|
//要将新节点插入到链表中
|
|
|
|
|
if(phead==NULL)
|
|
|
|
|
//要将新节点插入到链表中
|
|
|
|
|
if(phead==NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
phead=pnewnode;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
phead=pnewnode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pnewnode->pnext=phead;
|
|
|
|
|
phead=pnewnode;
|
|
|
|
|
|
|
|
|
|
phead=pnewnode;
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("请输入学生学号:\n");
|
|
|
|
@ -146,163 +135,143 @@ void Inputstudent()
|
|
|
|
|
printf("请输入学生电话:\n");
|
|
|
|
|
scanf("%s",pnewnode->stu.tel);
|
|
|
|
|
|
|
|
|
|
printf("\n录入学生信息成功!\n\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\n录入学生信息成功!\n\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//打印学生信息
|
|
|
|
|
void Printstudent()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Printstudent() //打印学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 1A");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t欢迎使用湖南工业大学学生信息管理系统\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
//遍历链表
|
|
|
|
|
node* p=phead;//定义一个当前节点
|
|
|
|
|
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 1A");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t欢迎使用湖南工业大学学生信息管理系统\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
//遍历链表
|
|
|
|
|
node* p=phead; //定义一个当前节点
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t当前总人数: %d\t\t\t\n",count);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf("\t\t当前总人数: %d\t\t\t\n",count);
|
|
|
|
|
}
|
|
|
|
|
//保存学生信息
|
|
|
|
|
void Savestudent()
|
|
|
|
|
|
|
|
|
|
void Savestudent() //保存学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 1B");
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen("stu.dat","w"); //打开文件
|
|
|
|
|
fp=fopen("stu.dat","wb+"); //打开文件
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("打开文件失败!\n\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//写入数据
|
|
|
|
|
node* p=phead;//当前节点
|
|
|
|
|
node* p=phead; //当前节点
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
fwrite(&p->stu,sizeof(student),1,fp);
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
printf("\n\n数据存入成功!\n\n");
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//查找学生信息
|
|
|
|
|
void Lookstudent()
|
|
|
|
|
|
|
|
|
|
void Lookstudent() //查找学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 1B");
|
|
|
|
|
char name[20];
|
|
|
|
|
char num[12];
|
|
|
|
|
|
|
|
|
|
node* p=phead;//定义一个当前节点
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 2F");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t欢迎使用湖南工业大学学生信息管理系统\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t请选择查找方式\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t|***************************************************************************************|\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t1.按姓名查找\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t2.按学号查找\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t0.退出查找系统\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("请输入查找的方式:\n\n");
|
|
|
|
|
char ch=getch();//从键盘输入一个字符
|
|
|
|
|
switch(ch)
|
|
|
|
|
char ch;
|
|
|
|
|
node* p=phead; //定义一个当前节点
|
|
|
|
|
do{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 2F");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t欢迎使用湖南工业大学学生信息管理系统\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t请选择查找方式\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t|***************************************************************************************|\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t1.按姓名查找\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t2.按学号查找\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t|\t\t\t\t0.退出查找系统\t\t\t\t\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("请输入您的选择:\n\n");
|
|
|
|
|
ch=getch(); //从键盘输入一个字符
|
|
|
|
|
switch(ch)
|
|
|
|
|
{
|
|
|
|
|
case '1':// 按姓名查找
|
|
|
|
|
|
|
|
|
|
printf("请输入学生姓名:\n");
|
|
|
|
|
scanf("%s",name);
|
|
|
|
|
case '1': //按姓名查找
|
|
|
|
|
printf("请输入学生姓名:\n");
|
|
|
|
|
scanf("%s",name);
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(strcmp(p->stu.name,name)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
}
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
case '2'://按学号查找
|
|
|
|
|
printf("请输入学生学号:\n");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(strcmp(p->stu.num,num)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
}
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(p->stu.name,name)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '2': //按学号查找
|
|
|
|
|
printf("请输入学生学号:\n");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(p->stu.num,num)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
}
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case '0'://退出系统
|
|
|
|
|
printf("ByeBye 欢迎再次使用!\n\n");
|
|
|
|
|
case '0': //退出系统
|
|
|
|
|
system("cls");
|
|
|
|
|
yanshi("\n\n\n\n\t\t\t\t\tByeBye 欢迎再次使用!\n\n");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("您输入有误,请重新输入!\n\n");
|
|
|
|
|
default:
|
|
|
|
|
printf("您输入有误,请重新输入!\n\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(count==0)
|
|
|
|
|
{
|
|
|
|
|
printf("没有您要查找的学生信息!\n\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while(ch!='0');
|
|
|
|
|
}
|
|
|
|
|
//修改学生信息
|
|
|
|
|
void Modifystudent()
|
|
|
|
|
|
|
|
|
|
void Modifystudent() //修改学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 1B");
|
|
|
|
|
char name[20];
|
|
|
|
|
|
|
|
|
|
node* p=phead;//定义一个当前节点
|
|
|
|
|
printf("\n\n请输入要修改的学生姓名:\n\n");
|
|
|
|
|
int j=0;
|
|
|
|
|
node* p=phead; //定义一个当前节点
|
|
|
|
|
printf("请输入要修改的学生姓名:\n");
|
|
|
|
|
scanf("%s",name);
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(p->stu.name,name)==0)
|
|
|
|
|
{
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("请修改学生信息!\n\n");
|
|
|
|
|
printf("\n请修改学生信息!\n");
|
|
|
|
|
|
|
|
|
|
printf("请输入学生学号:\n");
|
|
|
|
|
scanf("%s",p->stu.num);
|
|
|
|
|
|
|
|
|
@ -326,76 +295,84 @@ void Modifystudent()
|
|
|
|
|
|
|
|
|
|
printf("\n修改学生信息成功!\n\n");
|
|
|
|
|
system("pause");
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
system("cls");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|学号\t|姓名\t|性别\t|年龄\t|生日\t|家庭住址\t\t|本人电话\t\t|\n");
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
printf("\t\t|---------------------------------------------------------------------------------------|\n");
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
printf("\t\t*****************************************************************************************\n");
|
|
|
|
|
}
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
if(count==0)
|
|
|
|
|
if(j==0)
|
|
|
|
|
{
|
|
|
|
|
printf("没有您要修改的学生信息!\n\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//读取学生信息
|
|
|
|
|
void Readstudent()
|
|
|
|
|
|
|
|
|
|
void Readstudent() //读取学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 0F");
|
|
|
|
|
FILE *fp;
|
|
|
|
|
fp=fopen("stu.dat","r");
|
|
|
|
|
fp=fopen("stu.dat","rb");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("打开文件失败!\n\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//读取数据
|
|
|
|
|
node* p=phead;//当前节点
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
node* p=phead; //当前节点
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
fread(&p->stu,sizeof(student),1,fp);
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
|
|
|
|
|
printf("\t\t|%s\t|%s\t|%s\t|%d\t|%s\t|%s\t\t|%s\t\t|\n",p->stu.num,p->stu.name,p->stu.sex,p->stu.age,p->stu.birth,p->stu.home,p->stu.tel);
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
printf("\n\n数据读取完毕!!!\n\n");
|
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
|
|
printf("\n\n数据读取完毕!!!\n\n");
|
|
|
|
|
}
|
|
|
|
|
//删除学生信息
|
|
|
|
|
void Deletestudent()
|
|
|
|
|
|
|
|
|
|
void Deletestudent() //删除学生信息
|
|
|
|
|
{
|
|
|
|
|
system("cls");
|
|
|
|
|
system("color 6A");
|
|
|
|
|
char name[20];
|
|
|
|
|
|
|
|
|
|
node* p=phead;//定义一个当前节点
|
|
|
|
|
int j=0;
|
|
|
|
|
node* p=phead; //定义一个当前节点
|
|
|
|
|
node* p1=phead;
|
|
|
|
|
printf("\n\n请输入要删除的学生姓名:\n");
|
|
|
|
|
scanf("%s",name);
|
|
|
|
|
while(p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
while(strcmp(p->stu.name,name)!=0&&p!=NULL)
|
|
|
|
|
{
|
|
|
|
|
p1=p;
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(p->stu.name,name)==0)
|
|
|
|
|
if(strcmp(p->stu.name,name)!=0)
|
|
|
|
|
{
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
printf("删除学生信息成功!\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p=p->pnext;
|
|
|
|
|
if(p=phead)
|
|
|
|
|
{
|
|
|
|
|
phead=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
p1->pnext=p->pnext;
|
|
|
|
|
}
|
|
|
|
|
if(count==0)
|
|
|
|
|
printf("删除学生信息成功!\n\n");
|
|
|
|
|
printf("别忘记保存!\n\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yanshi(char *p) //延时函数的定义
|
|
|
|
|
{
|
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
printf("没有您要删除的学生信息!\n\n");
|
|
|
|
|
if (*p!=0)
|
|
|
|
|
printf("%c",*p++);
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
Sleep(100); //延时控制间断语句
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -409,5 +386,3 @@ p=p->pnext;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|