学生管理系统c语言(可运行)

更新时间:2024-05-07 23:49:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

/* *版权

*作者 姚树谦 *时间 2014.8.14 *修改日期 2014.8.21 * */

/************头文件包含**************/ #include #include #include #include\#include\#include\#include\#include\

/************结构定义宏定义**********/ #define MAIN_MENU 1 #define STU_ACCESS 11

#define STU_MAIN_MENU 111 #define TEA_ACCESS 12

#define TEA_MAIN_MENU 121 #define TEA_MEND_STU 1213 #define ADMIN_MAIN_MENU 13 #define ADMIN_ACCESS 131 #define STU_CHANGE 1311 #define STU_MEND 13113 #define SEARCH_STU 13114 #define SHOW_STU 13115 #define TEA_CHANGE 1312 #define TEA_MEND 13123 #define SEARCH_TEA 13124 #define EXIT_MENU 0

/************全局变量定义************/

/************函数原型申明************/

/************函数实现****************/

/*********************************************************************/ int printMenu(int state) { int choice;

打印登陆菜单

system(\ printhead(); printf(\学生登陆\\n\

printf(\教师登陆\\n\ printf(\管理员登陆\\n\ printf(\退出\\n\ scanf(\ if((choice>=1)&&(choice<=3)) return state*10+choice; else if(choice==4) return EXIT_MENU; else { printf(\请重新输入:\ return state; } }

/*********************************打************************************/ int printstudent_landMenu(int state,stu *q) { int choice; int num; int mystery; stu s=NULL; s=head; system(\ printhead1(); printf(\输入学号\\n\ printf(\退出\\n\ scanf(\ switch(choice) { case 1: system(\ printf(\请输入学号:\ scanf(\ if(num>=10000&&num<=999999) { while(s!=NULL) { if(s->num==num) {

学生登页面

印陆 }

}

*q=s; break; } else s=s->next; }

if(s==NULL) { printf(\请输入正确的学号,任意键继续\\n\ getchar(); getchar(); return state; } else { printf(\请输入密码:\ scanf(\ if(mystery>=10000&&mystery<=999999&&s->mystery==mystery) return STU_MAIN_MENU; else { printf(\请输入六位有效的数字密码,任意键继续\\n\ getchar(); getchar(); return STU_ACCESS; } } } else { printf(\哎呀!出错啦!请输入五~六位有效数字,任意键继续\\n\ getchar(); getchar(); return state; }

break;

case 2:return MAIN_MENU; break; default :

printf(\输入错误,请重新输入,任意键返回\\n\getchar();

getchar();return state;

/*********************************打印学生的主页面************************************/ int printstudentMenu(int stu_flag,stu q) { int choice,flag; int mystery; system(\ printhead1(); printf(\查看个人信息\\n\ printf(\查看本学期成绩\\n\ printf(\修改密码\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ scanf(\ switch(choice) { case 1: system(\ printf(\学号:%d 姓名:%s 密码:%d 级%d\\n\ getchar(); getchar(); return STU_MAIN_MENU; break; case 2: system(\ printf(\数学成绩:%d c语言成绩:%d \\n\ getchar(); getchar(); return STU_MAIN_MENU; break; case 3: printf(\输入新密码:\ scanf(\ q->mystery=mystery; printf(\修改成功 任意键返回\\n\ getchar(); getchar(); //printf(\修改成功 任意键返回\\n\ return STU_MAIN_MENU; break; case 4:return STU_ACCESS; break; case 5: return MAIN_MENU; break;

年龄:%d 语文成绩班:%d } if(flag==1) { printf(\按任意键返回\ getchar(); getchar(); return STU_MAIN_MENU; } }

/*********************************打************************************/ int printteacher_landMenu(int state,tea *q) { int choice; int num; int mystery; tea s=NULL; s=head1; system(\ printhead1(); printf(\输入教师序号\\n\ printf(\退出\\n\ scanf(\ //switch(choice) if(choice==1) { //case 1: system(\ printf(\请输入教师序号:\ scanf(\ if(num>=1000&&num<=99999) { while(s!=NULL) { if(s->num==num) { *q=s; break; } else s=s->next; } if(s==NULL) {

教师登页面

印陆

printf(\请输入正确的序号,任意键继续\\n\ getchar(); getchar(); return TEA_ACCESS; } else { printf(\请输入密码:\ scanf(\ if(s->mystery==mystery) return TEA_MAIN_MENU; else { printf(\请输入正确的密码,任意键继续\\n\ getchar(); getchar(); return TEA_ACCESS; } } } else { printf(\哎呀!出错啦 请输入五~六位有效数字,任意键返回\ getchar(); getchar(); return TEA_ACCESS; } } else if(choice==2) return MAIN_MENU; else { printf(\输入错误,请重新输入,任意键返回\\n\ getchar(); getchar(); return state; } }

/*********************************教师修改学生成绩的************************************/ int print_teamendStuMenu(sysState) { int choice;

主菜单 int num; int n;

stu s=NULL; s=head;

system(\

printf(\请输入要修改学生的学号:\\n\printf(\返回上一级\\n\scanf(\switch(n) {case 1:

printf(\输入学生的学号:\scanf(\while(s!=NULL) { if(s->num==num) break; else s=s->next; }

if(s==NULL) {

printf(\无此学生,请输入正确的学号,任意键继续\\n\getchar(); getchar();

return TEA_MAIN_MENU;//????? break;

case 2: return TEA_MAIN_MENU; } }

system(\printhead1();

printf(\修改数学成绩\\n\printf(\修改c语言成绩\\n\printf(\修改语文成绩\\n\printf(\返回上一级\\n\printf(\退出\\n\;

int math1,c_langue1,chinese1; scanf(\switch(choice) {

case 1:printf(\请输入新的数学成绩:\ //修改数学成绩 scanf(\ s->math=math1; printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_MEND_STU; break; case 2:printf(\请输入新的c语言成绩:\ //修改c语言成绩 scanf(\ s->c_langue=c_langue1; printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_MEND_STU; break; case 3:printf(\请输入新的语文成绩:\ scanf(\ s->chinese=chinese1; printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_MEND_STU; break; case 4:return TEA_MEND_STU; break; case 5:return MAIN_MENU; break; } }

/*********************************打************************************/ int printteacherMenu(int sysState,tea p) { int choice; int mystery; system(\ printhead1(); printf(\查看个人信息\\n\ printf(\查看所有学生的信息\\n\ printf(\修改学生的成绩\\n\ printf(\修改密码\\n\ printf(\返回上一级\\n\ printf(\退出\\n\

印老 //修改语文成绩 //返回学生管理界面 //返回主界面 师的主页面 scanf(\ switch(choice) { case 1: system(\ printf(\序号:%d 姓名:%s 密码:%d 所在班级%d\\n\ getchar(); getchar(); return TEA_MAIN_MENU; break; case 2: system(\ show_student(head); getchar(); getchar(); return TEA_MAIN_MENU; break; case 3: return sysState*10+choice; break; case 4: printf(\输入新密码:\ scanf(\ p->mystery=mystery; printf(\修改成功 任意键返回\\n\ getchar(); getchar(); //printf(\修改成功 任意键返回\\n\ return TEA_MAIN_MENU; break; case 5: return TEA_ACCESS; break; case 6: return MAIN_MENU; break; default: return TEA_ACCESS; } }

/*********************************打印1311************************************/ int print_mendStuMenu(sysState) { int choice; int num; stu s=NULL; s=head; system(\

修改学生信息的主菜单 printf(\请输入要修改学生的学号:\scanf(\while(s!=NULL) { if(s->num==num) break; else s=s->next; }

if(s==NULL) {

printf(\无此学生,请输入正确的学号,任意键继续\\n\getchar(); getchar();

return STU_CHANGE; }

system(\printhead1();

printf(\修改学号\\n\printf(\修改姓名\\n\printf(\修改密码\\n\printf(\修改年龄\\n\printf(\修改班级\\n\

printf(\修改数学成绩\\n\printf(\修改c语言成绩\\n\printf(\修改语文成绩\\n\printf(\返回上一级\\n\printf(\退出\\n\int num1;

char name1[20];

int mystery1,age1,cla1,math1,c_langue1,chinese1; scanf(\switch(choice) { case 1:printf(\请输入新的学号:\ scanf(\ s->num=num1; printf(\修改成功,任意键返回\ getchar(); getchar(); return STU_CHANGE; break; case 2:printf(\请输入新的姓名:\ scanf(\

//修改学号//修改姓名

strcpy(s->name,name1);

printf(\修改成功,任意键返回\getchar(); getchar();

return STU_CHANGE; break;

case 3:printf(\请输入新的密码:\ //修改密码 scanf(\s->mystery=mystery1;

printf(\修改成功,任意键返回\getchar(); getchar();

return STU_CHANGE; break;

case 4:printf(\请输入新的年龄:\ scanf(\s->age=age1;

printf(\修改成功,任意键返回\getchar(); getchar();

return STU_CHANGE; break;

case 5:printf(\请输入新的班级:\ scanf(\s->cla=cla1;

printf(\修改成功,任意键返回\getchar(); getchar();

return STU_CHANGE; break;

case 6:printf(\请输入新的数学成绩:\ scanf(\s->math=math1;

printf(\修改成功,任意键返回\getchar(); getchar();

return STU_CHANGE; break;

case 7:printf(\请输入新的c语言成绩:\ scanf(\s->c_langue=c_langue1;

printf(\修改成功,任意键返回\getchar(); getchar();

//修改年龄 //修改班级 //修改数学成绩 //修改c语言成绩 return STU_CHANGE; break; case 8:printf(\请输入新的语文成绩:\ //修改语文成绩 scanf(\ s->chinese=chinese1; printf(\修改成功,任意键返回\ getchar(); getchar(); return STU_CHANGE; break; case 9:return STU_CHANGE; break; case 0:return MAIN_MENU; break; } }

/*********************************打印1311************************************/ int printadmin_stuMenu(int sysState) { int d; int choice; int num; system(\ printhead1(); printf(\录入学生基本信息\\n\ printf(\删除学生信息\\n\ printf(\修改学生信息\\n\ printf(\查找学生信息\\n\ printf(\显示所有学生信息\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ while(1) { scanf(\ switch(choice) { case 1:system(\ student_insert(); break; case 2:printf(\输入要删除学生的学号:\ scanf(\ delete_stu(num); print_stu(head);

//返回学生管理界面 //返回主界面 管理学生的主菜单//打印管理学生的主菜单 1311 getchar(); getchar(); return STU_CHANGE; break; case 3:return sysState*10+choice; break; case 4:return sysState*10+choice; //查找学生 break; case 5:return sysState*10+choice; //show_student(head);getchar();getchar(); break; case 6:return ADMIN_ACCESS; break; case 7:return MAIN_MENU; break; } break; } return STU_CHANGE; }

/*********************************查找学生界面**************************************************/ int print_searchStuMenu(int sysState) { int choice; int num; int cla; stu s=NULL; char name[20]; system(\ printhead1(); printf(\根据学号查找\\n\ printf(\根据姓名查找\\n\ printf(\根据班级查找\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ scanf(\ switch(choice) {

/*********************************学号查找************************************/ case 1:printf(\请输入学号:\ scanf(\ s=search_student_num(num);

if(s==NULL) { printf(\抱歉!无此学生信息任意键返回\ getchar(); getchar(); return SEARCH_STU; } //print_stu(s); getchar(); getchar(); return SEARCH_STU; break;

/*********************************姓名查找************************************/ case 2:printf(\请输入姓名:\ scanf(\ s=search_student_name(name); if(s==NULL) { printf(\抱歉!无此学生信息任意键返回\ getchar(); getchar(); return SEARCH_STU; } print_stu(s); getchar(); getchar(); return SEARCH_STU; break;

/*********************************班级查找*************************************/ case 3:printf(\请输入班级:\ scanf(\ s=search_student_cla(cla); if(s==NULL) { printf(\抱歉!请输入正确的班级,任意键返回\ getchar(); getchar(); return SEARCH_STU; } print_stu(s); getchar(); getchar(); return SEARCH_STU; break;

/*********************************返回上一级***************************/ case 4:return STU_CHANGE; break;

/*********************************退出到主界面*************************/ case 5:return MAIN_MENU; break;

/*********************************其他情况返回上一级********************/

default:return STU_CHANGE; } }

int print_showStuMenu(int sysState) { int choice; float n; stu pnew=NULL; system(\ printhead1(); printf(\按学号顺序显示\\n\ printf(\按名次显示\\n\ printf(\按数学成绩顺序显示\\n\ printf(\按C语言成绩顺序显示\\n\ printf(\按语文成绩顺序显示\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ scanf(\ switch(choice) { case 1:system(\ showNum_sort(); print_stu(head); getchar(); getchar(); return sysState; break; case 2:system(\ marksum(); showSum_sort(); print_stu(head); getchar(); getchar(); return sysState; break; case 3:system(\ //按学号顺序显示

showMath_sort(); print_stu_math(head); //按数学成绩顺序显示+平均分 getchar(); getchar(); return sysState; break; case 4:system(\ //按c语言成绩顺序显示 showC_langue_sort(); //print_stu(head); print_stu_c_langue(head); getchar(); getchar(); return sysState; break; case 5:system(\ showchinese_sort(); //print_stu(head); print_stu_chinese(head); getchar(); getchar(); return sysState; break; case 6:return STU_CHANGE; break; case 7:return MAIN_MENU; break; default:return STU_CHANGE; 界面 } }

/*********************************打印1311************************************/ int print_mendTeaMenu(int sysState) { int choice; int num; tea s=NULL; s=head1; system(\ printf(\请输入要修改教师的序号:\ scanf(\ while(s!=NULL) { if(s->num==num)

//按语文成绩顺序显示 //返回学生管理界面 //返回主界面 //其它情况返回学生管理修改教师信息的主菜单 break; else s=s->next; }

if(s==NULL) {

printf(\无此教师,请输入正确的序号,任意键继续\\n\getchar(); getchar();

return TEA_CHANGE; }

system(\printhead1();

printf(\修改序号\\n\printf(\修改姓名\\n\printf(\修改密码\\n\

printf(\修改所在班级\\n\printf(\返回上一级\\n\printf(\退出\\n\int num1;

char name1[20]; int mystery1,cla1; scanf(\switch(choice) { case 1:printf(\请输入新的序号:\ scanf(\ s->num=num1; printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_CHANGE; break; case 2:printf(\请输入新的姓名:\ scanf(\ strcpy(s->name,name1); printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_CHANGE; break; case 3:printf(\请输入新的密码:\ scanf(\ s->mystery=mystery1;

//修改学号//修改姓名//修改密码 printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_CHANGE; break; case 4:printf(\请输入新的班级:\ //修改班级 scanf(\ s->cla=cla1; printf(\修改成功,任意键返回\ getchar(); getchar(); return TEA_CHANGE; break; case 9:return TEA_CHANGE; //返回教师管理界面 break; case 0:return MAIN_MENU; //返回主界面 break; } }

/*********************************查找教师界面**************************************************/ int print_searchTeaMenu(int sysState) { int choice; int num; int cla; tea s=NULL; char name[20]; system(\ printhead1(); printf(\根据教师序号查找\\n\ printf(\根据姓名查找\\n\ printf(\根据所在班级查找\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ scanf(\ switch(choice) {

/*********************************序号查找************************************/ case 1:printf(\请输入教师序号:\ scanf(\ s=search_teacher_num(num); if(s==NULL) {

printf(\抱歉!无此教师信息任意键返回\ getchar(); getchar(); return SEARCH_TEA; } //print_stu(s); getchar(); getchar(); return SEARCH_TEA; break;

/*********************************姓名查找************************************/ case 2:printf(\请输入姓名:\ scanf(\ s=search_teacher_name(name); if(s==NULL) { printf(\抱歉!无此教师信息任意键返回\ getchar(); getchar(); return SEARCH_TEA; } print_tea(s); getchar(); getchar(); return SEARCH_TEA; break;

/*********************************班级查找*************************************/ case 3:printf(\请输入所在班级:\ scanf(\ s=search_teacher_cla(cla); if(s==NULL) { printf(\抱歉!请输入正确的班级,任意键返回\ getchar(); getchar(); return SEARCH_TEA; } print_tea(s); getchar(); getchar(); return SEARCH_TEA; break;

/*********************************返回上一级***************************/ case 4:return TEA_CHANGE;

break;

/*********************************退出到主界面*************************/ case 5:return MAIN_MENU; break;

/*********************************其他情况返回上一级********************/ default:return TEA_CHANGE; } }

/*********************************打印管理老师的菜1312******************************/ int printadmin_teaMenu(int sysState) { int choice; int num; system(\ printhead1(); printf(\录入教师基本信息\\n\ printf(\删除教师信息\\n\ printf(\修改教师信息\\n\ printf(\查找教师信息\\n\ printf(\显示所有老师的信息\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ scanf(\ switch(choice) { case 1:system(\ teacher_insert(); return TEA_CHANGE; break; case 2:printf(\输入要删除老师的序号:\ scanf(\ delete_tea(num); print_tea(head1); getchar(); getchar(); return TEA_CHANGE; break; case 3:return sysState*10+choice; break; case 4:return sysState*10+choice; break; case 5:show_teacher(head1); getchar();

getchar(); return TEA_CHANGE; break; case 6:return ADMIN_ACCESS; break; case 7:return MAIN_MENU; break; default:return ADMIN_ACCESS; } }

/*********************************管理员管理老师和学生的总界面************************************/ int printadminMenu_131(int sysState) { int choice; system(\ printhead1(); printf(\学生管理\\n\ printf(\教师管理\\n\ printf(\返回上一级\\n\ printf(\退出\\n\ scanf(\ if(choice==1||choice==2) //分别进入管理老师或学生的界面 return sysState*10+choice; else if(choice==3) return ADMIN_MAIN_MENU; else return MAIN_MENU; }

/*********************************打印管理员的主菜单************************************/

int printadminMenu(int admin_flag)//admin_flag==13 { char name[5]=\ char mystery[5]=\ int choice=admin_flag; system(\ printhead1(); printf(\输入用户名:\\n\ printf(\退出\\n\ scanf(\ if(choice==1) {

system(\ //管理员登陆 printf(\用户名:\ //输入用户名 scanf(\ if(strcmp(\ { printf(\输入密码:\ scanf(\ //输入密码 if(strcmp(\ { return admin_flag*10+choice; } else return ADMIN_MAIN_MENU; } else return ADMIN_MAIN_MENU; } else if(choice==2) return MAIN_MENU; else return ADMIN_MAIN_MENU; }

/*********************************主菜单************************************/ stu main_menu() { stu q=NULL; tea p=NULL; int sysState=MAIN_MENU; int exit_flag=1; while(1) { switch(sysState) { case MAIN_MENU:sysState=printMenu(sysState);//MAIN_MENU 1 break; case STU_ACCESS:sysState=printstudent_landMenu(sysState,&q);//STU_ACCESS 11 break; case

STU_MAIN_MENU:sysState=printstudentMenu(sysState,q);//STU_MAIN_MENU 111 break; case TEA_ACCESS:sysState=printteacher_landMenu(sysState,&p);//TEA_ACCESS 12 break; case

TEA_MAIN_MENU:sysState=printteacherMenu(sysState,p);//TEA_MAIN_MENU 121 break; case

TEA_MEND_STU:sysState=print_teamendStuMenu(sysState);//TEA_MEND_STU 1213 break; case

ADMIN_MAIN_MENU:sysState=printadminMenu(sysState);//ADMIN_MAIN_MENU 13 break; case ADMIN_ACCESS:sysState=printadminMenu_131(sysState);//ADMIN_ACCESS 131 break; case STU_CHANGE:sysState=printadmin_stuMenu(sysState);//STU_CHANGE 1311(管理学生界面) break; case STU_MEND:sysState=print_mendStuMenu(sysState);//STU_MEND 13113(修改学生信息) break; case SEARCH_STU:sysState=print_searchStuMenu(sysState);//SEARCH_STU 13114(查找学生) break; case SHOW_STU:sysState=print_showStuMenu(sysState);//SHOW_STU 13115(显示学生) break; case TEA_CHANGE:sysState=printadmin_teaMenu(sysState);//TEA_CHANGE 1312 break; case TEA_MEND:sysState=print_mendTeaMenu(sysState);//TEA_MEND 13123(修改教师信息) break; case SEARCH_TEA:sysState=print_searchTeaMenu(sysState);//SEARCH_TEA 13124(查找教师) break; case EXIT_MENU:exit_flag=0;break; default:printf(\输入错误,请重新输入:\\n\ } if(exit_flag==0) break; } return head; }

/*********************************主函数************************************/ int main() { read(); read_tea();

}

main_menu(); write(); write_tea();

本文来源:https://www.bwwdw.com/article/i1og.html

Top