|
|
|
@ -0,0 +1,471 @@
|
|
|
|
|
# include<windows.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#include<stdio.h>
|
|
|
|
|
#define N 100
|
|
|
|
|
struct student
|
|
|
|
|
{
|
|
|
|
|
char no[9];
|
|
|
|
|
char name[25];
|
|
|
|
|
char sex[10];
|
|
|
|
|
int age;
|
|
|
|
|
char jiguan[25];
|
|
|
|
|
char xibie[25];
|
|
|
|
|
char zhuanye[25];
|
|
|
|
|
int ban;
|
|
|
|
|
}stu[N];
|
|
|
|
|
void menu()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int choice,w1;
|
|
|
|
|
void add();void find();void shanchu();void change();void tongji();
|
|
|
|
|
void read();void input();
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
puts("\t******************************");
|
|
|
|
|
puts("\t* 欢迎使用学籍管理系统 *");
|
|
|
|
|
puts("\t* 1 录入学生资料 *");
|
|
|
|
|
puts("\t* 2查找学生资料 *");
|
|
|
|
|
puts("\t* 3删除学生资料 *");
|
|
|
|
|
puts("\t* 4修改学生资料 *");
|
|
|
|
|
puts("\t* 5按学号或专业输出所有学生资料*");
|
|
|
|
|
puts("\t* 6查看所有学生资料 *");
|
|
|
|
|
puts("\t 7退出系统 *");
|
|
|
|
|
puts("\t***********************************");
|
|
|
|
|
printf("想选择的功能:");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>8)
|
|
|
|
|
{
|
|
|
|
|
w1=1;printf("菜单选择错误,请重新选择\n");}
|
|
|
|
|
else
|
|
|
|
|
w1=0;
|
|
|
|
|
}while(w1==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
add();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
find();
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
shanchu();
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
change();
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
tongji();
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
read();
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int load()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i;
|
|
|
|
|
if((fp=fopen("result.txt","a+"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("文件打开错误");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
for(i=0;feof(fp);i++)
|
|
|
|
|
fread(&stu[i],sizeof(struct student),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return(i-1);
|
|
|
|
|
}
|
|
|
|
|
//********保存函数
|
|
|
|
|
void save(int n)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
FILE*fp;
|
|
|
|
|
if((fp=fopen("results.txt","a+"))=NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("文件打开错误");
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
fwrite(&stu[i],sizeof(struct student),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
void read()
|
|
|
|
|
{
|
|
|
|
|
int n,m,k;
|
|
|
|
|
n=load();
|
|
|
|
|
printf("输入你录入了多少学生信息");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
printf("学号\t姓名\t性别\t年龄\t籍贯\t系别\t专业\t班级\t");
|
|
|
|
|
for(m=0;m<k;m++)
|
|
|
|
|
{
|
|
|
|
|
printf("\n%s",stu[m].no);
|
|
|
|
|
printf("\t%s",stu[m].name);
|
|
|
|
|
printf("\t%s",stu[m].sex);
|
|
|
|
|
printf("\t%d",stu[m].age);
|
|
|
|
|
printf("\t%s",stu[m].jiguan);
|
|
|
|
|
printf("\t%s",stu[m].xibie);
|
|
|
|
|
printf("\t%s",stu[m].zhuanye);
|
|
|
|
|
printf("\t%d",stu[m].ban);
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
int xz ,choice;//选择返回还是退出系统的变量
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n1-返回主菜单; 2-退出系统\n");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>2)
|
|
|
|
|
{xz=1;system("cls");printf("输入错误,请重新选择!\n");
|
|
|
|
|
}
|
|
|
|
|
else xz=0;
|
|
|
|
|
}while(xz==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//*********录入学生的信息
|
|
|
|
|
void add()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i,m,n;
|
|
|
|
|
n=0;
|
|
|
|
|
if((fp=fopen("results.txt","wb"))=NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("文件打开错误\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
printf("你想录入多少个学生的信息?");
|
|
|
|
|
scanf("%d",&m);
|
|
|
|
|
for(i=0;i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("\n学号;");
|
|
|
|
|
scanf("%s",stu[n+i].no);
|
|
|
|
|
printf("姓名");
|
|
|
|
|
scanf("%s",stu[n+i].name);
|
|
|
|
|
printf("籍贯");
|
|
|
|
|
scanf("%s",stu[n+i].jiguan);
|
|
|
|
|
printf("系别");
|
|
|
|
|
scanf("%s",stu[n+i].xibie);
|
|
|
|
|
printf("性别");
|
|
|
|
|
scanf("%s",stu[n+i].sex);
|
|
|
|
|
printf("年龄");
|
|
|
|
|
scanf("%d",&stu[n+i].age);
|
|
|
|
|
printf("专业");
|
|
|
|
|
scanf("%s",stu[n+i].zhuanye);
|
|
|
|
|
printf("班级");
|
|
|
|
|
scanf("%d",&stu[n+i].ban);
|
|
|
|
|
printf("输入完成");
|
|
|
|
|
}
|
|
|
|
|
save(m);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
{
|
|
|
|
|
int xz,choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n-1返回主菜单;2-退出系统\n");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>2)
|
|
|
|
|
{xz=1;system("cls");
|
|
|
|
|
printf("输入错误,请重新选择!\n");}
|
|
|
|
|
else xz=0;
|
|
|
|
|
}while(xz==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
menu();break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//****查找函数******//
|
|
|
|
|
void find()
|
|
|
|
|
{
|
|
|
|
|
int menu();
|
|
|
|
|
int i,n;
|
|
|
|
|
char m[9];
|
|
|
|
|
n=load();
|
|
|
|
|
printf("\t\t\t 欢迎使用学号查找功能\n请输入你需要查找的学生的学号;");
|
|
|
|
|
scanf("%s",&m);
|
|
|
|
|
if(!strcmp(stu[i].no,m))
|
|
|
|
|
{
|
|
|
|
|
printf("学号\t性别\t年龄\t籍贯\t系统\t专业\t班级\n");
|
|
|
|
|
printf("%s",stu[i].no);
|
|
|
|
|
printf("\t%s",stu[i].name);
|
|
|
|
|
printf("\t%s",stu[i].sex);
|
|
|
|
|
printf("\t%d",stu[i].age);
|
|
|
|
|
printf("\t%s",stu[i].jiguan);
|
|
|
|
|
printf("\t%s",stu[i].xibie);
|
|
|
|
|
printf("\t%s",stu[i].zhuanye);
|
|
|
|
|
printf("\t%d\n",stu[i].ban);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
printf("你输入的学号错误");
|
|
|
|
|
{
|
|
|
|
|
int xz,choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n 1-返回主菜单; 2-退出系统\n");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>2)
|
|
|
|
|
{xz=1;system("cls");printf("输入错误,请重新选择!\n");}
|
|
|
|
|
else xz=0;
|
|
|
|
|
}while(xz==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
menu();break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//修改函数
|
|
|
|
|
void change()
|
|
|
|
|
{
|
|
|
|
|
int n,i,j;
|
|
|
|
|
|
|
|
|
|
char m[9];
|
|
|
|
|
n=load();
|
|
|
|
|
printf("欢迎使用修改功能\n输入你要修改学生的学号");
|
|
|
|
|
scanf("%s",&m);
|
|
|
|
|
if(!strcmp(stu[i].no,m))
|
|
|
|
|
{
|
|
|
|
|
printf("你要修改的项目;\n1)学号 2)姓名 3)性别 4)年龄 5)籍贯 6)系别 7)专业 8)班级\n");
|
|
|
|
|
printf("你选择的功能是;");
|
|
|
|
|
scanf("%d",&j);
|
|
|
|
|
switch(j)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
printf("输入你修改后的学号;");
|
|
|
|
|
scanf("%s,stu[i].name");
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
printf("请输入你修改后的姓名;");
|
|
|
|
|
scanf("%s",stu[i].name);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
printf("请输入你修改后的性别;");
|
|
|
|
|
scanf("%s,stu[i].sex");
|
|
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
printf("输入你修改后的年龄;");
|
|
|
|
|
scanf("%d",&stu[i].age);
|
|
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
printf("请输入你修改后的籍贯;");
|
|
|
|
|
scanf("%s",stu[i].jiguan);
|
|
|
|
|
break;
|
|
|
|
|
case 6:
|
|
|
|
|
printf("输入你修改后的系别;");
|
|
|
|
|
scanf("%s",stu[i].xibie);
|
|
|
|
|
break;
|
|
|
|
|
case 7:
|
|
|
|
|
printf("请输入你修改后的专业;");
|
|
|
|
|
scanf("%s",stu[i].zhuanye);
|
|
|
|
|
break;
|
|
|
|
|
case 8:
|
|
|
|
|
printf("请输入你修改后的班级;");
|
|
|
|
|
scanf("%d",&stu[i].ban);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("选择功能错误\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
save(1);
|
|
|
|
|
{
|
|
|
|
|
int xz,choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n 1-返回主菜单; 2-退出系统\n");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>2)
|
|
|
|
|
{xz=1;system("cls");printf("输入错误,请重新选择!\n");
|
|
|
|
|
}
|
|
|
|
|
else xz =0;
|
|
|
|
|
}while(xz==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//**********统计函数
|
|
|
|
|
void tongji_1()//按学号统计
|
|
|
|
|
{
|
|
|
|
|
int n,i,sum=0;
|
|
|
|
|
char m[9];
|
|
|
|
|
n=load();
|
|
|
|
|
printf("请输入你要统计的学号;");
|
|
|
|
|
scanf("%s",&m);
|
|
|
|
|
printf("学号\t姓名\t性别\t年龄\t籍贯\t系别\t专业\t班级\n");
|
|
|
|
|
for(i=0;!strcmp(m,stu[i].zhuanye);i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%s",stu[i].no);
|
|
|
|
|
printf("\t%s",stu[i].name);
|
|
|
|
|
printf("\t%s",stu[i].sex);
|
|
|
|
|
printf("\t%d",stu[i].age);
|
|
|
|
|
printf("\t%s",stu[i].jiguan);
|
|
|
|
|
printf("\t%s",stu[i].xibie);
|
|
|
|
|
printf("\t%s",stu[i].zhuanye);
|
|
|
|
|
printf("\t%d\n",stu[i].ban);
|
|
|
|
|
sum++;
|
|
|
|
|
printf("%s学号的学生共有%d个\n",m,sum);}
|
|
|
|
|
}
|
|
|
|
|
void tongji_2()//按专业统计
|
|
|
|
|
{
|
|
|
|
|
int n,i,sum=0;
|
|
|
|
|
char m[25];
|
|
|
|
|
n=load();
|
|
|
|
|
printf("请输入你需要统计的专业;");
|
|
|
|
|
scanf("%s",&m);
|
|
|
|
|
printf("学号\t姓名\t性别\t年龄\t籍贯\t专业\t班级\n");
|
|
|
|
|
for(i=0;!strcmp(m,stu[i].zhuanye);i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%s",stu[i].no);
|
|
|
|
|
printf("\t%s",stu[i].name);
|
|
|
|
|
printf("\t%s",stu[i].sex);
|
|
|
|
|
printf("\t%d",stu[i].age);
|
|
|
|
|
printf("\t%s",stu[i].jiguan);
|
|
|
|
|
printf("\t%s",stu[i].xibie);
|
|
|
|
|
printf("\t%s",stu[i].zhuanye);
|
|
|
|
|
printf("\t%d\n",stu[i].ban);
|
|
|
|
|
sum++;
|
|
|
|
|
printf("%s专业的学生共有%d个\n",m,sum);}
|
|
|
|
|
}
|
|
|
|
|
void tongji()
|
|
|
|
|
{
|
|
|
|
|
int n,m;
|
|
|
|
|
n=load();
|
|
|
|
|
printf("欢迎使用统计功能\n你想统计的项目是;1) 学号\t 2)专业\n");
|
|
|
|
|
printf("输入你想选择的功能;");
|
|
|
|
|
scanf("%d",&m);
|
|
|
|
|
switch(m)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
tongji_1();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
tongji_2();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
printf("选择的功能错误\n");
|
|
|
|
|
int getch();
|
|
|
|
|
tongji();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
int xz,choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n 1-返回主菜单; 2-退出系统\n");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>2)
|
|
|
|
|
{xz=1,system("cls");printf("输入错误,请重新选择!\n");
|
|
|
|
|
}
|
|
|
|
|
else xz =0;
|
|
|
|
|
}while(xz==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//**************删除函数
|
|
|
|
|
void shanchu()
|
|
|
|
|
{
|
|
|
|
|
int n,j,i,k;
|
|
|
|
|
char m[9];
|
|
|
|
|
n=load();
|
|
|
|
|
printf("请输入你需要删除多少个信息");
|
|
|
|
|
scanf("%d",&k);
|
|
|
|
|
printf("请输入你要删除资料学生的学号");
|
|
|
|
|
scanf("%s",&m);
|
|
|
|
|
for(i=0;i<k;i++)
|
|
|
|
|
{
|
|
|
|
|
if(!strcmp(stu[i].no,m))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
strcpy(stu[j].no,stu[j+1].no);
|
|
|
|
|
strcpy(stu[j].name,stu[j+1].name);
|
|
|
|
|
stu[j].age=stu[j+1].age;
|
|
|
|
|
strcpy(stu[j].jiguan,stu[j+1].jiguan);
|
|
|
|
|
strcpy(stu[j].xibie,stu[j+1].xibie);
|
|
|
|
|
strcpy(stu[j].zhuanye,stu[j+1].zhuanye);
|
|
|
|
|
strcpy(stu[j].sex,stu[j+1].sex);
|
|
|
|
|
stu[j].ban=stu[j+1].ban;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
printf("没有你输入的学号");
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
int xz,choice;
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
printf("\n 1-返回主菜单; 2-退出系统\n");
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
if(choice<1||choice>2)
|
|
|
|
|
{xz=1,system("cls");printf("输入错误,请重新选择!\n");
|
|
|
|
|
}
|
|
|
|
|
else xz =0;
|
|
|
|
|
}while(xz==1);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{
|
|
|
|
|
case 1:
|
|
|
|
|
menu();
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
exit(0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|