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