C语言实现学生信息管理系统(文件版)
程序员文章站
2022-05-11 22:48:21
本文实例为大家分享了c语言实现学生信息管理系统的具体代码,供大家参考,具体内容如下下面是我自己用写的学生信息管理系统,为了增加数据的利用率,分为学生端和教师端,同时实现账号密码登录,以文件的形式将其存...
本文实例为大家分享了c语言实现学生信息管理系统的具体代码,供大家参考,具体内容如下
下面是我自己用写的学生信息管理系统,为了增加数据的利用率,分为学生端和教师端,同时实现账号密码登录,以文件的形式将其存入。
代码如下
#include <stdio.h> #include <string.h> #include <string> #include<windows.h> #define user "tom" // 事先定义用户名,用于登录页面,验证身份。 #define pw "123456789" // 事先定义密码 ,作用同上。 void level_menu();//主菜单的声明--选择学生端还是老师端。 void level_2_menu(); //二级菜单——具体功能分化 void student_add_level_3_menu();// 增添学生信息菜单功能分化 void student_insert(); //添加单个学生信息 void student_insert1(); /*为上面批量输入设置的函数,其代码与上面的 单个输入相似,删减了一部分*/ void student_tongji_menu();//统计菜单部分 void student_tongji_menu2();//统计二级菜单 void student_tongji_menu3();//统计 void io_readinfo();/*将学生信息从文件(student database.txt)中读出*/ void io_writeinfo();/*将学生信息写入文件(database.txt)*/ void student_delete_menu(); /*删除学生信息菜单*/ void student_menu1();/*学生查询课程信息菜单*/ void student_kecheng_menu2(); void student_from_high_to_low1(); /*按综合测评从高到低排序*/ void jiangxue_menu();/*奖学金评定办法*/ void student_display2();/*显示学生信息2在奖学金评定时使用*/ /*定义学生结构体*/ struct student { char id[20]; //学号 char name[20]; //姓名 char sushe[6]; //宿舍房间号 float matha1; //高等数学成绩 float englisha1; //大学英语成绩 float software; //软件技术导论 float china_history;//中国近代史纲要 float junshi; //军事教育 float xinli; //心理健康辅导 float sports; //体育*/ float c_mark; //c语言程学设计成绩 float pingjun; //总学分 float banzhuren; //班主任评分 float cepingfen; //测评分 }; /*声明学生数组及学生数量*/ struct student students[1000]; int num=0; int num; /*通过学号返回数组下标*/ int student_searchbyindex(char id[]) { int i; for (i=0;i<num;i++) { if (strcmp(students[i].id,id)==0) { return i; } } return -1; } /*通过姓名返回数组下标*/ int student_searchbyname(char name[]) { int i; for (i=0;i<num;i++) { if (strcmp(students[i].name,name)==0) { return i; } } return -1; } /*通过宿舍成员返回数组下标*/ void student_searchbysushe() { system("cls"); system("color f0"); int i; char sushe[6] ; printf("请输入你想要查询的宿舍房间号: "); scanf("%s",&sushe); printf("%10s%10s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号","高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","总学分","班主任评分","测评分"); printf("------------------------------------------------------------------------------------------------------------------------\n"); for (i=0;i<num;i++) { if (strcmp(students[i].sushe,sushe)==0) { printf("%10s%10s%5s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].id,students[i].name,students[i].sushe,students[i].matha1,students[i].englisha1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].c_mark,students[i].pingjun,students[i].banzhuren,students[i].cepingfen); } } printf("数据加载完毕!"); student_tongji_menu2(); } /*显示单条学生记录*/ void student_displaysingle(int index) { printf("%10s%10s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号","高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","品行分"); printf("------------------------------------------------------------------------------------------------------------------------\n"); printf("%10s%10s%5s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[index].id,students[index].name,students[index].sushe,students[index].matha1,students[index].englisha1,students[index].software,students[index].china_history,students[index].junshi,students[index].xinli,students[index].sports,students[index].c_mark,students[index].pingjun); } /*增加单条学生记录*/ void student_insert() { system("cls"); system("color f0"); float a1,a2,a3,a4,a5,a6,a7,a8; float j=0; while(1) { printf("请输入学号:"); scanf("%s",&students[num].id); getchar(); printf("请输入姓名:"); scanf("%s",&students[num].name); getchar(); printf("请输入宿舍号:"); scanf("%s",&students[num].sushe); getchar(); printf("请输入高等数学成绩:"); scanf("%f",&students[num].matha1); getchar(); if (59<students[num].matha1 && students[num].matha1<100) a8= 1.5; else a8=0; printf("请输入大学英语成绩:"); scanf("%f",&students[num].englisha1); getchar(); if (59<students[num].englisha1 && students[num].englisha1<100) a1= 2; else a1=0; printf("请输入软件技术导论成绩:"); scanf("%f",&students[num].software); getchar(); if (59<students[num].software && students[num].software<100) a2= 1.5; else a2=0; printf("请输入中国近代史纲要成绩:"); scanf("%f",&students[num].china_history); getchar(); if (59<students[num].china_history && students[num].china_history<100) a3= 2.5; else a3=0; printf("请输入军事教育:"); scanf("%f",&students[num].junshi); getchar(); if (59<students[num].junshi && students[num].junshi<100) a4= 2; else { a4=0; } printf("请输入心理健康教育成绩:"); scanf("%f",&students[num].xinli); getchar(); if (59<students[num].xinli && students[num].xinli<100) a5= 1.5; else a5=0; printf("请输入体育成绩:"); scanf("%f",&students[num].sports); getchar(); if (59<students[num].sports && students[num].sports<100) a6= 2; else a6=0; printf("请输入c语言成绩:"); scanf("%f",&students[num].c_mark); getchar(); if (59<students[num].c_mark && students[num].c_mark<100) a7= 3.5; else a7=0; printf("请输入班主任评分:"); scanf("%f",&students[num].banzhuren); getchar(); students[num].pingjun=a1+a2+a3+a4+a5+a6+a7+a8; //总学分 j=(students[num].pingjun*0.4)+(students[num].banzhuren*0.6); students[num].cepingfen=j; num++; printf("是否继续?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { num=num; break; } } } /*批量添加学生记录*/ void student_many1() { { system("cls"); system("color f0"); int i,j; printf("请输入你将要添加的人员数: "); scanf("%d",&j); for(i=0;i<j;i++) { student_insert1(); } printf("成员添加完毕,是否跳转至上一级菜单?\n"); printf("是?,请按任意键,确认输入: \n"); if (getchar()=='y') { student_add_level_3_menu(); } } } /*为上面批量输入设置的函数,其代码与上面的 单个输入相似,删减了一部分*/ void student_insert1() { { printf("请输入学号:"); scanf("%s",&students[num].id); getchar(); printf("请输入姓名:"); scanf("%s",&students[num].name); getchar(); printf("请输入宿舍号:"); scanf("%s",&students[num].sushe); getchar(); printf("请输入高等数学成绩:"); scanf("%f",&students[num].matha1); getchar(); printf("请输入大学英语成绩:"); scanf("%f",&students[num].englisha1); getchar(); printf("请输入软件技术导论成绩:"); scanf("%f",&students[num].software); getchar(); printf("请输入中国近代史纲要成绩:"); scanf("%f",&students[num].china_history); getchar(); printf("请输入军事教育:"); scanf("%f",&students[num].junshi); getchar(); printf("请输入心理健康教育成绩:"); scanf("%f",&students[num].xinli); getchar(); printf("请输入体育成绩:"); scanf("%f",&students[num].sports); getchar(); printf("请输入c语言成绩:"); scanf("%f",&students[num].c_mark); getchar(); printf("请输入班主任评分:"); scanf("%f",&students[num].banzhuren); getchar(); if (54<students[num].c_mark && students[num].c_mark< 60) //把55~59分之间的成绩都加上5分 { students[num].c_mark += 5; } num++; } } /*修改学生信息*/ void student_modify() { system("cls"); system("color f0"); float a1,a2,a3,a4,a5,a6,a7,a8; float j=0; while(1) { char id[20]; int index; printf("请输入要修改的学生的学号:"); scanf("%s",&id); getchar(); index=student_searchbyindex(id); if (index==-1) { printf("该学生不存在!\n"); } else { printf("你要修改的学生信息为:\n"); student_displaysingle(index); printf("-- 请输入新值--\n"); /*printf("请输入学号:"); scanf("%s",&students[index].id); getchar(); printf("请输入姓名:"); scanf("%s",&students[index].name); getchar(); printf("请输入宿舍号:"); scanf("%s",&students[index].sushe); getchar(); printf("请输入高等数学成绩:"); scanf("%f",&students[index].matha1); getchar(); printf("请输入大学英语成绩:"); scanf("%f",&students[index].englisha1); getchar(); printf("请输入软件技术导论成绩:"); scanf("%f",&students[index].software); getchar(); printf("请输入中国近代史纲要成绩:"); scanf("%f",&students[index].china_history); getchar(); printf("请输入军事教育:"); scanf("%f",&students[index].junshi); getchar(); printf("请输入心理健康教育成绩:"); scanf("%f",&students[index].xinli); getchar(); printf("请输入体育成绩:"); scanf("%f",&students[index].sports); getchar(); printf("请输入c语言成绩:"); scanf("%f",&students[index].c_mark); getchar(); printf("请输入班主任评分:"); scanf("%f",&students[num].banzhuren); getchar();*/ printf("请输入学号:"); scanf("%s",&students[index].id); getchar(); printf("请输入姓名:"); scanf("%s",&students[index].name); getchar(); printf("请输入宿舍号:"); scanf("%s",&students[index].sushe); getchar(); printf("请输入高等数学成绩:"); scanf("%f",&students[index].matha1); getchar(); if (59<students[index].matha1 && students[index].matha1<100) a8= 1.5; else a8=0; printf("请输入大学英语成绩:"); scanf("%f",&students[index].englisha1); getchar(); if (59<students[index].englisha1 && students[index].englisha1<100) a1= 2; else a1=0; printf("请输入软件技术导论成绩:"); scanf("%f",&students[index].software); getchar(); if (59<students[index].software && students[index].software<100) a2= 1.5; else a2=0; printf("请输入中国近代史纲要成绩:"); scanf("%f",&students[index].china_history); getchar(); if (59<students[index].china_history && students[index].china_history<100) a3= 2.5; else a3=0; printf("请输入军事教育:"); scanf("%f",&students[index].junshi); getchar(); if (59<students[index].junshi && students[index].junshi<100) a4= 2; else { a4=0; } printf("请输入心理健康教育成绩:"); scanf("%f",&students[index].xinli); getchar(); if (59<students[index].xinli && students[index].xinli<100) a5= 1.5; else a5=0; printf("请输入体育成绩:"); scanf("%f",&students[index].sports); getchar(); if (59<students[index].sports && students[index].sports<100) a6= 2; else a6=0; printf("请输入c语言成绩:"); scanf("%f",&students[index].c_mark); getchar(); if (59<students[index].c_mark && students[index].c_mark<100) a7= 3.5; else a7=0; printf("请输入班主任评分:"); scanf("%f",&students[index].banzhuren); getchar(); students[index].pingjun=a1+a2+a3+a4+a5+a6+a7+a8; //总学分 j=(students[index].pingjun*0.4)+(students[index].banzhuren*0.6); students[index].cepingfen=j; } printf("是否继续?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { break; } } } /*按学号删除学生信息*/ void student_delete() { system("cls"); system("color f0"); io_readinfo(); int i; while(1) { char id[20]; int index; printf("请输入要删除的学生的学号:"); scanf("%s",&id); getchar(); index=student_searchbyindex(id); if (index==-1) { printf("学生不存在!\n"); } else { printf("你要删除的学生信息为:\n"); student_displaysingle(index); printf("%d",index); printf("%d",num); { for (i=index;i<num-1;i++) { students[i]=students[i+1]; //把后边的对象都向前移动 } num--; } printf("已删除\n"); io_writeinfo(); } printf("是否继续删除?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { break; } } } /*按姓名删除学生信息*/ void student_delete_1() { system("cls"); system("color f0"); io_readinfo(); int i; while(1) { char name[20]; int index; printf("请输入要删除的学生的姓名: "); scanf("%s",&name); getchar(); index=student_searchbyname(name); if (index==-1) { printf("学生不存在!\n"); } else { printf("你要删除的学生信息为:\n"); student_displaysingle(index); { for (i=index;i<num-1;i++) { students[i]=students[i+1]; //把后边的对象都向前移动 } num--; } printf("已删除\n"); io_writeinfo(); } printf("是否继续删除?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { break; } } } /*按姓名查询*/ void student_select_1() { while(1) { char name[20]; int index; printf("请输入要查询的学生的姓名:"); scanf("%s",&name); getchar(); index=student_searchbyname(name); if (index==-1) { printf("学生不存在!\n"); } else { printf("你要查询的学生信息为:\n"); student_displaysingle(index); } printf("是否继续?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { break; } } } /*按学号查找*/ void student_select_2() { while(1) { char id[20]; int index; system("cls"); system("color f0"); printf("请输入要查询的学生的学号:"); scanf("%s",&id); getchar(); index=student_searchbyindex(id); if (index==-1) { printf("学生不存在!\n"); } else { printf("你要查询的学生信息为:\n"); student_displaysingle(index); } printf("是否继续?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { break; } } } void student_search_menu() { int choice; while(1) { system("cls"); system("color f0"); printf("\t\t\t\t\t\t1. 按姓名查询学生记录\n"); printf("\t\t\t\t\t\t2. 按学号查询学生记录\n"); printf("\t\t\t\t\t\t3. 返回上一级菜单\n"); printf("\t\t\t\t\t\t4. 返回主菜单\n"); printf("\t\t\t\t\t\t请选择(1-4):"); scanf("%d",&choice); getchar(); switch(choice) { case 1:student_select_1(); break; case 2:student_select_2(); break; case 3:level_2_menu(); break; case 4:level_menu(); break; } } } /*按c语言成绩从高到低排序*/ void student_from_high_to_low() { int i,j; struct student tmp; for (i=0;i<num;i++) { for (j=1;j<num-i;j++) { if (students[j-1].c_mark<students[j].c_mark) { tmp=students[j-1]; students[j-1]=students[j]; students[j]=tmp; } } } } /*按c语言成绩从低到高排序*/ void student_from_low_to_high() { int i,j; struct student tmp; for (i=0;i<num;i++) { for (j=1;j<num-i;j++) { if (students[j-1].c_mark>students[j].c_mark) { tmp=students[j-1]; students[j-1]=students[j]; students[j]=tmp; } } } } /*按综合测评从高到低排序*/ void student_from_high_to_low1() { int i,j,k; struct student tmp; for (i=0;i<num;i++) { for (j=1;j<num-i;j++) { if (students[j-1].cepingfen<students[j].cepingfen) { tmp=students[j-1]; students[j-1]=students[j]; students[j]=tmp; } } } /*system("cls"); system("color f0"); while(1) { int k; printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号"," 高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","品行分","班主任评分","测评分"); printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); for (k=0;k<num;k++) { if(59<students[k].matha1&&students[k].matha1<101&&59<students[k].englisha1&&students[k].englisha1<101&&59<students[k].software&&students[k].software<101&&59<students[k].china_history&&students[k].china_history<101&&59<students[k].junshi&&students[k].junshi<101&&59<students[k].xinli&&students[k].xinli<101&&59<students[k].sports&&students[k].sports<101&&59<students[k].c_mark&&students[k].c_mark<101); { printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[k].id,students[k].name,students[k].sushe,students[k].matha1,students[k].englisha1,students[k].software,students[k].china_history,students[k].junshi,students[k].xinli,students[k].sports,students[k].c_mark,students[k].pingjun,students[k].banzhuren,students[k].cepingfen); } } printf("数据加载完毕!"); jiangxue_menu(); student_tongji_menu3(); } */ } /*奖学金评定办法*/ void jiangxue_menu() { float i=0,j=0,k=0; int a,b,c; i=num*0.1; j=num*0.15; k=num*0.2; a=(int)i; b=(int)j; c=(int)k; printf("一等奖获得人数为:%d\n",a); printf("二等奖获奖人数为:%d\n",b); printf("三等奖获奖人数为:%d\n",c); } //对奖学金及格的人员筛选出来 void jiangxue() { system("cls"); system("color f0"); while(1) { int k; printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号"," 高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","品行分","班主任评分","测评分"); printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); for (k=0;k<num;k++) { if(59<students[k].matha1&&students[k].matha1<101&&59<students[k].englisha1&&students[k].englisha1<101&&59<students[k].software&&students[k].software<101&&59<students[k].china_history&&students[k].china_history<101&&59<students[k].junshi&&students[k].junshi<101&&59<students[k].xinli&&students[k].xinli<101&&59<students[k].sports&&students[k].sports<101&&59<students[k].c_mark&&students[k].c_mark<101); { printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[k].id,students[k].name,students[k].sushe,students[k].matha1,students[k].englisha1,students[k].software,students[k].china_history,students[k].junshi,students[k].xinli,students[k].sports,students[k].c_mark,students[k].pingjun,students[k].banzhuren,students[k].cepingfen); } } printf("数据加载完毕!"); jiangxue_menu(); student_tongji_menu3(); } } /*显示学生信息*/ void student_display() { system("cls"); system("color f0"); while(1) { int i; printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号"," 高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","品行分"); printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); for (i=0;i<num;i++) { printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].id,students[i].name,students[i].sushe,students[i].matha1,students[i].englisha1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].c_mark,students[i].pingjun); } printf("是否继续?(y/n),继续请按任意键,否则输入n:"); if (getchar()=='n') { break; } } } /*显示学生信息1*/ void student_display1() { system("cls"); system("color f0"); while(1) { int i; printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号"," 高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","品行分","班主任评分","测评分"); printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); for (i=0;i<num;i++) { printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].id,students[i].name,students[i].sushe,students[i].matha1,students[i].englisha1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].c_mark,students[i].pingjun,students[i].banzhuren,students[i].cepingfen); } printf("数据加载完毕!"); student_tongji_menu3(); } } /*显示学生信息2在奖学金评定时使用*/ void student_display2() { system("cls"); system("color f0"); while(1) { int i; printf("%10s%10s %8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s%8s\n","学号","姓名","宿舍号"," 高等数学","大学英语","软件技术导论","中国近代史","军事教育","心理健康教育","大学体育","c语言成绩","品行分","班主任评分","测评分"); printf("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n"); for (i=0;i<num;i++) { printf("%10s%10s %8s %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n",students[i].id,students[i].name,students[i].sushe,students[i].matha1,students[i].englisha1,students[i].software,students[i].china_history,students[i].junshi,students[i].xinli,students[i].sports,students[i].c_mark,students[i].pingjun,students[i].banzhuren,students[i].cepingfen); } printf("数据加载完毕!"); jiangxue_menu(); student_tongji_menu3(); } } /*将学生信息从文件(student database.txt)中读出*/ void io_readinfo() { file *fp; int i; if ((fp=fopen("student database.txt","rb"))==null) { printf("不能打开文件!\n"); return; } if (fread(&num,sizeof(int),1,fp)!=1) { num=-1; } else { for(i=0;i<num;i++) { fread(&students[i],sizeof(struct student),1,fp); } } fclose(fp); } /*将学生信息写入文件(database.txt)*/ void io_writeinfo() { file *fp; int i; if ((fp=fopen("student database.txt","wb"))==null) { printf("不能打开文件!\n"); return; } if (fwrite(&num,sizeof(int),1,fp)!=1) { printf("写入文件错误!\n"); } for (i=0;i<num;i++) { if (fwrite(&students[i],sizeof(struct student),1,fp)!=1) { printf("写入文件错误!\n"); } } fclose(fp); } /*一级菜单*/ /*账号密码登录*/ void level_1_menu( ) { char account[20]; char password[30]; int i = 0; int j = 3; for (; i < 3; i++){ printf("\n\n\n\n\t\t\t\t\t\t *主菜单*\n"); printf("\t\t\t\t\t\t******************\n"); printf("\t\t\t\t\t\t*请输入您的账号:*\n"); printf("\t\t\t\t\t\t******************\n"); printf(" 请输入:"); scanf ("%s", account); printf("\t\t\t\t\t\t******************\n"); //scanf ("%s", account); printf("\t\t\t\t\t\t******************\n"); printf("\t\t\t\t\t\t*请输入您的密码:*\n"); printf("\t\t\t\t\t\t******************\n"); printf(" 请输入:"); scanf ("%s", password); if (strcmp(user, account) == 0 && strcmp(pw, password) == 0){ printf("登录成功!\n"); break; } else{ j--; printf("登录失败您还有%d次机会!\n", j); } } if (i == 3){ printf("登录失败,退出!"); } //system("pause"); system("cls"); system("color f0"); } /*增加学生信息三级菜单模块*/ void student_add_level_3_menu() { int choice; while(1) { system("cls"); system("color f0"); io_readinfo(); //读取文件 printf("\t\t\t\t\t\t1. 单个添加学生信息\n"); printf("\t\t\t\t\t\t2. 批量添加学生信息\n"); printf("\t\t\t\t\t\t3. 返回上一级菜单\n"); printf("\t\t\t\t\t\t4. 返回主菜单\n"); printf("\t\t\t\t\t\t请选择(1-4):"); scanf("%d",&choice); getchar(); switch(choice) { case 1:student_insert(); io_writeinfo(); //写入文件 break; case 2:student_many1(); io_writeinfo(); //写入文件 break; case 3:level_2_menu(); break; case 4:level_menu(); break; } io_writeinfo(); //写入文件 } //student_insert(); } /*二级菜单*/ /*主菜单*/ void level_2_menu( ) { int choice; while(1) { /*二级菜单*/ /*主菜单*/ system("cls"); system("color f0"); io_readinfo(); //读取文件 printf("\n\t\t\t\t\t\t------ 学生成绩管理系统------\n"); printf("\t\t\t\t\t\t1. 增加学生记录\n"); printf("\t\t\t\t\t\t2. 修改学生记录\n"); printf("\t\t\t\t\t\t3. 删除学生记录\n"); printf("\t\t\t\t\t\t4. 查询学生记录\n"); printf("\t\t\t\t\t\t5. 统计学生记录\n"); printf("\t\t\t\t\t\t6. 退出\n"); printf("\t\t\t\t\t\t请选择(1-6):"); scanf("%d",&choice); getchar(); switch(choice) { case 1: student_add_level_3_menu(); break; case 2: student_modify(); break; case 3: student_delete_menu(); break; case 4: student_search_menu(); break; case 5: student_tongji_menu(); break; case 6: level_menu(); break; } io_writeinfo(); } } /*学生端成绩查询模块*/ void student_delete_menu() { int choice; while(1) { system("cls"); system("color f0"); io_readinfo(); //读取文件 printf("\n\n\n\n\t\t\t\t\t\t************************\n"); printf("\t\t\t\t\t\t* 删除学生信息菜单******\n"); printf("\t\t\t\t\t\t************************\n"); printf("\t\t\t\t\t\t*1、按姓名删除信息 *\n"); printf("\t\t\t\t\t\t*2、按学号删除信息 *\n"); printf("\t\t\t\t\t\t*3、返回上一级功能菜单 *\n"); printf("\t\t\t\t\t\t*4、返回主菜单 *\n"); printf("\t\t\t\t\t\t************************\n"); printf("\t\t\t\t\t\t************************\n"); printf(" 请选择(1-4):"); scanf("%d",&choice); switch(choice) { case 1: system("cls"); system("color f0"); student_delete_1(); break; case 2: system("cls"); system("color f0"); student_delete(); break; case 3: level_2_menu(); break; case 4: level_menu(); break; } io_writeinfo(); } } /*学生端成绩查询模块*/ void student_menu() { int choice; while(1) { system("cls"); system("color f0"); io_readinfo(); //读取文件 printf("\n\n\n\n\t\t\t\t\t\t*******************\n"); printf("\t\t\t\t\t\t* 学生菜单 *\n"); printf("\t\t\t\t\t\t*******************\n"); printf("\t\t\t\t\t\t*1、按姓名查询成绩*\n"); printf("\t\t\t\t\t\t*2、按学号查询成绩*\n"); printf("\t\t\t\t\t\t*3、查询课程信息 *\n"); printf("\t\t\t\t\t\t*4、退出 *\n"); printf("\t\t\t\t\t\t*******************\n"); printf("\t\t\t\t\t\t*******************\n"); printf(" 请选择(1-3):"); scanf("%d",&choice); switch(choice) { case 1: system("cls"); system("color f0"); student_select_1(); break; case 2: student_select_2(); break; case 3: student_menu1(); break; case 4: level_menu(); break; } io_writeinfo(); } } void student_kecheng_menu1() { printf("\n\n\n\n\t\t\t\t\t\t************************************************\n"); printf("\t\t\t\t\t\t* 课程代号 课程名称 学分 必修/选修*\n"); printf("\t\t\t\t\t\t*b27020100 中国近现代史纲要 2.0 必修 *\n"); printf("\t\t\t\t\t\t*b10060111 大学英语a1 4.0 必修 *\n"); printf("\t\t\t\t\t\t*b14010101 大学体育1 2.0 必修 *\n"); printf("\t\t\t\t\t\t*b06010111 高等数学a1 5.0 必修 *\n"); printf("\t\t\t\t\t\t*b08050101 软件技术导论 2.0 必修 *\n"); printf("\t\t\t\t\t\t*b08010100 c语言程序设计 5.0 必修 *\n"); printf("\t\t\t\t\t\t*b08010201 c语言程序设计实训1 2.0 必修 *\n"); printf("\t\t\t\t\t\t*b08056601 创新与指导实践1 1.0 必修 *\n"); printf("\t\t\t\t\t\t*b21991100 军事教育 2.0 选修 *\n"); printf("\t\t\t\t\t\t**************************************************\n"); printf("\t\t\t\t\t\t**************************************************\n"); printf("\t\t\t\t\t\t1. 返回上一级菜单\n"); printf("\t\t\t\t\t\t2. 返回主菜单\n"); printf("\t\t\t\t\t\t请选择(1-2):"); int choice; scanf("%d",&choice); while(1) switch(choice) { case 1:student_menu1(); break; case 2:level_menu(); break; } //写入文件 } void student_kecheng_menu2() { printf("\n\n\n\n\t\t\t\t\t\t************************************************\n"); printf("\t\t\t\t\t\t* 课程代号 课程名称 学分 必修/选修*\n"); printf("\t\t\t\t\t\t*b27010100 思想道德修养 3.0 必修 *\n"); printf("\t\t\t\t\t\t*b10060112 大学英语a2 4.0 必修 *\n"); printf("\t\t\t\t\t\t*b14010102 大学体育2 2.0 必修 *\n"); printf("\t\t\t\t\t\t*b06010112 高等数学a2 5.0 必修 *\n"); printf("\t\t\t\t\t\t*b08052200 数字逻辑设计 2.0 必修 *\n"); printf("\t\t\t\t\t\t*b06050131 大学物理c1 2.5 必修 *\n"); printf("\t\t\t\t\t\t*b06020100 离散数学 4.0 必修 *\n"); printf("\t\t\t\t\t\t*b08056601 创新与指导实践2 1.0 必修 *\n"); printf("\t\t\t\t\t\t*b21991100 c语言程序设计实践2 2.0 选修 *\n"); printf("\t\t\t\t\t\t**************************************************\n"); printf("\t\t\t\t\t\t**************************************************\n"); printf("\t\t\t\t\t\t1. 返回上一级菜单\n"); printf("\t\t\t\t\t\t2. 返回主菜单\n"); printf("\t\t\t\t\t\t请选择(1-2):"); int choice; scanf("%d",&choice); while(1) switch(choice) { case 1:student_menu1(); break; case 2:level_menu(); break; } //写入文件 } /*学生端学生课程查询模块*/ void student_menu1() { int choice; while(1) { system("cls"); system("color f0"); io_readinfo(); //读取文件 printf("\n\n\n\n\t\t\t\t\t\t*******************\n"); printf("\t\t\t\t\t\t* 课程信息 *\n"); printf("\t\t\t\t\t\t*******************\n"); printf("\t\t\t\t\t\t*1、第一学期 *\n"); printf("\t\t\t\t\t\t*2、第二学期 *\n"); printf("\t\t\t\t\t\t*3、第三学期 *\n"); printf("\t\t\t\t\t\t*4、第四学期 *\n"); printf("\t\t\t\t\t\t*5、第五学期 *\n"); printf("\t\t\t\t\t\t*6、第六学期 *\n"); printf("\t\t\t\t\t\t*7、第七学期 *\n"); printf("\t\t\t\t\t\t*8、退出 *\n"); printf("\t\t\t\t\t\t*******************\n"); printf("\t\t\t\t\t\t*******************\n"); printf(" 请选择(1-3):"); scanf("%d",&choice); switch(choice) { case 1: system("cls"); system("color f0"); student_kecheng_menu1(); break; case 2: system("cls"); system("color f0"); student_kecheng_menu2(); break; case 3: break; case 4: break; case 5: break; case 6: break; case 7: break; case 8: level_menu(); break; } io_writeinfo(); } } /*统计菜单模块*/ void student_tongji_menu() { int choice; while(1) { system("cls"); system("color f0"); io_readinfo(); //读取文件 printf("\n\n\n\n\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t* 学生统计菜单 *\n"); printf("\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t*1、按c语言成绩从高到低排序 *\n"); printf("\t\t\t\t\t\t*2、按c语言成绩从低到高排序 *\n"); printf("\t\t\t\t\t\t*3、按宿舍成员进行统计 *\n"); printf("\t\t\t\t\t\t*4、奖学金评定 *\n"); printf("\t\t\t\t\t\t*5、返回功能菜单 *\n"); printf("\t\t\t\t\t\t*6、返回主菜单 *\n"); printf("\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t******************************\n"); printf(" 请选择(1-5):"); scanf("%d",&choice); switch(choice) { case 1: student_from_high_to_low(); student_display1(); break; case 2: student_from_low_to_high(); student_display1(); break; case 3: student_searchbysushe(); break; case 4: student_from_high_to_low1(); student_display2(); break; case 5: level_2_menu( ); break; case 6: level_menu(); break; } io_writeinfo(); } } /*统计菜单模块*/ void student_tongji_menu2() { int choice; while(1) { io_readinfo(); //读取文件 printf("\n\n\n\n\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t* 你目前在学生宿舍统计页面! *\n"); printf("\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t*1、返回上一级统计菜单 *\n"); printf("\t\t\t\t\t\t*2、返回功能选择菜单 *\n"); printf("\t\t\t\t\t\t*3、返回主菜单 *\n"); printf("\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t******************************\n"); printf(" 请选择(1-3):"); scanf("%d",&choice); switch(choice) { case 1: system("cls"); system("color f0"); student_tongji_menu(); case 2: system("cls"); system("color f0"); level_2_menu( ); case 3: system("cls"); system("color f0"); level_menu(); } } } /*统计菜单模块*/ void student_tongji_menu3() { int choice; while(1) { io_readinfo(); //读取文件 printf("\n\n\n\n\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t* 你目前按c语言成绩统计页面!*\n"); printf("\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t*1、返回上一级统计菜单 *\n"); printf("\t\t\t\t\t\t*2、返回功能选择菜单 *\n"); printf("\t\t\t\t\t\t*3、返回主菜单 *\n"); printf("\t\t\t\t\t\t******************************\n"); printf("\t\t\t\t\t\t******************************\n"); printf(" 请选择(1-3):"); scanf("%d",&choice); switch(choice) { case 1: system("cls"); system("color f0"); student_tongji_menu(); case 2: system("cls"); system("color f0"); level_2_menu( ); case 3: system("cls"); system("color f0"); level_menu(); } } } /*第一级主菜单学生or老师的判断*/ void level_menu() { int choice; while(1) { system("cls"); system("color f0"); printf("\n\n\n\n\n\n\n\t\t\t\t\t\t******************\n"); printf("\t\t\t\t\t\t*1、教师端 *\n"); printf("\t\t\t\t\t\t*2、学生端 *\n"); printf("\t\t\t\t\t\t*3、退出 *\n"); printf("\t\t\t\t\t\t******************\n"); printf(" 请选择(1-3):"); scanf("%d",&choice); switch(choice) { case 1: system("cls"); system("color f0"); level_1_menu(); //一级菜单,密码登录。 io_readinfo(); //读取文件 level_2_menu(); //二级菜单-主菜单 io_writeinfo(); break; case 2: student_menu(); break; case 3: exit(0); break; } } } /***********主程序*********/ main() { level_menu(); }
关于管理系统的更多内容请点击《管理系统专题》进行学习
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。