系统设计综述
题目
学生信息管理系统模拟
功能
该系统能够模拟学生基本信息管理。
成绩评定
整个系统开发分为三个部分,总分20分,如果有缺勤情况,每缺勤一次扣1分,上不封顶。
整体要求
? 该系统应具有合理的界面设计,并易于操作;
? 编码风格良好;
? 该系统用控制台程序即可实现;
? 编程语言为C语言,编程环境为VC++ 6.0
第一部分 存储结构设计
任务
设计学生结构体。
编程要求
1. 结构体设计
“学生”结构体包含“学号”、“姓名”、“性别”、“英语成绩”、“C语言成绩”。
2. 存储结构要求
在实现各个模块的功能时, 根据该模块的具体要求确定存储结构。
任务
设计学生结构体。
编程要求
1. 结构体设计
“学生”结构体包含“学号”、“姓名”、“性别”、“英语成绩”、“C语言成绩”。
2. 存储结构要求
在实现各个模块的功能时, 根据该模块的具体要求确定存储结构。
第二部分 菜单(界面)设计
任务
编程实现系统的菜单
编程要求
“登陆”菜单(选做,有加分)
1———-用户登陆
0———-退出系统
任务
编程实现系统的菜单
编程要求
“登陆”菜单(选做,有加分)
1———-用户登陆
0———-退出系统
主菜单样式如下:
1———-学生录入
2———-学生浏览
3———-学生查询
4———-学生删除
5———-成绩统计
0———-退出系统
1———-学生录入
2———-学生浏览
3———-学生查询
4———-学生删除
5———-成绩统计
0———-退出系统
第三部分 功能和函数设计
任务
通过函数完成各个菜单模块的功能,要求合理设计主函数和各个子函数,合理设计各个函数之间的调用关系。
编程要求
1. 主函数:显示主菜单。
2. 如果设计并编写登陆菜单,要求合理设计登陆界面,要求用户输入用户名和密码,如果全都正确则进入主菜单,如果有一项不对,系统再提供两次机会输入,三次都错退出系统。(此部分有加分)
3. 编写函数完成“学生录入”功能,要求能将用户由键盘输入的若干学生信息追加到student.txt或student.dat中,存储结构可以使用数组,也可以使用链表。
4. 编写函数完成“学生浏览”功能,要求能将student.txt或student.dat文件中的全部学生信息显示出来,存储结构可以使用数组,也可以使用链表。
5. 编写函数完成“学生查询”功能,要求能按照学号或姓名对学生进行查询。
6. 编写函数完成“学生删除”功能,要求按照学号或姓名将某个学生删除,并将删除后的结果写回到文件中,此功能要求存储结构必须使用链表。
7. 设计并编写编写函数完成“成绩统计”功能,可以对“英语成绩”、“C语言成绩”进行单科浏览(降序排列),按某个学生统计总分和平均分,按英语和C语言两科成绩对学生进行排序。
第四部分 进度要求
任务
通过函数完成各个菜单模块的功能,要求合理设计主函数和各个子函数,合理设计各个函数之间的调用关系。
编程要求
1. 主函数:显示主菜单。
2. 如果设计并编写登陆菜单,要求合理设计登陆界面,要求用户输入用户名和密码,如果全都正确则进入主菜单,如果有一项不对,系统再提供两次机会输入,三次都错退出系统。(此部分有加分)
3. 编写函数完成“学生录入”功能,要求能将用户由键盘输入的若干学生信息追加到student.txt或student.dat中,存储结构可以使用数组,也可以使用链表。
4. 编写函数完成“学生浏览”功能,要求能将student.txt或student.dat文件中的全部学生信息显示出来,存储结构可以使用数组,也可以使用链表。
5. 编写函数完成“学生查询”功能,要求能按照学号或姓名对学生进行查询。
6. 编写函数完成“学生删除”功能,要求按照学号或姓名将某个学生删除,并将删除后的结果写回到文件中,此功能要求存储结构必须使用链表。
7. 设计并编写编写函数完成“成绩统计”功能,可以对“英语成绩”、“C语言成绩”进行单科浏览(降序排列),按某个学生统计总分和平均分,按英语和C语言两科成绩对学生进行排序。
第四部分 进度要求
? 进度要求
第2教学周——第3教学周:完成第一部分、第二部分以及第三部分的“学生录入”、“学生查询”和“学生浏览”功能。
第4教学周——第5教学周:完成“学生删除”和“成绩统计”功能。
第6教学周:教师完成对学生程序的考核
第2教学周——第3教学周:完成第一部分、第二部分以及第三部分的“学生录入”、“学生查询”和“学生浏览”功能。
第4教学周——第5教学周:完成“学生删除”和“成绩统计”功能。
第6教学周:教师完成对学生程序的考核
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<io.h> FILE *file; char user[25],pwd[25]; typedef struct student { char num[12]; char name[24]; char sex[8]; int score_eng; int score_com; struct student *next; struct student *last; }stu; void setnewuser() //创建新管理员用户 { char username[25],pwd[25],repwd[25]; while(1){ printf("您是第一次访问本系统,需要创建一个管理员用户,n"); printf("请输入用户名:n"); gets(username); printf("请输入密码:n"); gets(pwd); printf("请再次输入密码:n"); gets(repwd); if(strcmp(pwd,repwd)==0) { printf("创建成功!n"); file=fopen("student.dat","w"); fprintf(file,"%s %sn",username,pwd); fclose(file); return; } else { system("cls"); printf("两次输入密码不同,请重试!n"); } } } int login() //登录接口主程序 { int t,select; char checkuser[25],checkpwd[25]; system("cls"); while(1) { printf("请选择您的操作!n"); printf("1.登陆n"); printf("0.退出n"); scanf("%d",&select); getchar(); if(select==0) return 0; else if(select==1) break; system("cls"); printf("录入有误,请重试!n"); } system("cls"); printf("请登录!n"); printf("请输入用户名:n"); file=fopen("student.dat","r"); fscanf(file,"%s %s",user,pwd); fclose(file); gets(checkuser); for(t=1;t<=3;t++) { printf("请输入密码:n"); gets(checkpwd); if(strcmp(user,checkuser)==0&&strcmp(pwd,checkpwd)==0) { system("cls"); printf("登陆成功!n"); return 1; } printf("密码错误!n"); } printf("密码错误次数过多,系统将退出!"); return 0; } void insert() { char num[12],name[25],sex[8]; int score_eng,score_com,select; file=fopen("student.dat","at"); while(1) { system("cls"); printf("请输入学生数据(学号,姓名,性别,英语成绩,C语言成绩),空缺用0补位n"); scanf("%s %s %s %d %d",num,name,sex,&score_eng,&score_com); getchar(); fprintf(file,"%s %s %s %d %dn",num,name,sex,score_eng,score_com); system("cls"); printf("操作成功!n"); while(1) { printf("1.继续添加数据n"); printf("0.返回主菜单n"); scanf("%d",&select); getchar(); if(select==1) break; else if(select==0) { system("cls"); fclose(file); return; } else { system("cls"); printf("输入的选项有误,请重新输入!n"); } } } } void view() { char num[12],name[25],sex[8],tmp[50]; int score_eng,score_com; getchar(); system("cls"); file=fopen("student.dat","r"); printf("学号t姓名tt性别t英语tC语言n"); fgets(tmp,50,file); //过滤首行用户名密码 while(fscanf(file,"%s %s %s %d %d",num,name,sex,&score_eng,&score_com)!=EOF) printf("%st%stt%st%dt%dn",num,name,sex,score_eng,score_com); fclose(file); system("pause"); system("cls"); } void find() { char num[12],name[25],sex[8],tmp[50]; int score_eng,score_com; stu *head=NULL,*p; system("cls"); printf("请输入学号或姓名!n"); file=fopen("student.dat","r"); fgets(tmp,50,file); scanf("%s",tmp); getchar(); printf("学号t姓名tt性别t英语tC语言n"); while(fscanf(file,"%s %s %s %d %d",num,name,sex,&score_eng,&score_com)!=EOF) { if(strcmp(tmp,num)==0||strcmp(tmp,name)==0) printf("%st%stt%st%dt%dn",num,name,sex,score_eng,score_com); } system("pause"); system("cls"); fclose(file); } void del() { char num_tmp[12],name_tmp[25],sex_tmp[8],tmp[50]; int score_eng_tmp,score_com_tmp,key=0; stu *head=NULL,*p,*last_tmp=NULL; system("cls"); file=fopen("student.dat","r"); getchar(); fgets(tmp,50,file); printf("请输入要删除的学号或姓名:n"); scanf("%s",tmp); while(fscanf(file,"%s %s %s %d %d",num_tmp,name_tmp,sex_tmp,&score_eng_tmp,&score_com_tmp)!=EOF) { if(strcmp(tmp,num_tmp)==0||strcmp(tmp,name_tmp)==0) { key++; continue; } p=(stu *)malloc(sizeof(stu)); p->next=head; if(p->next!=NULL) p->next->last=p; head=p; strcpy(p->num,num_tmp); strcpy(p->name,name_tmp); strcpy(p->sex,sex_tmp); p->score_eng=score_eng_tmp; p->score_com=score_com_tmp; } p->last=NULL; if(key==0) { system("cls"); printf("未找到您要找的信息!n"); system("pause"); system("cls"); getchar(); return; } file=fopen("student.dat","w"); fprintf(file,"%s %sn",user,pwd); while(p->next!=NULL) p=p->next; while(p!=NULL) { fprintf(file,"%s %s %s %d %dn",p->num,p->name,p->sex,p->score_eng,p->score_com); p=p->last; } fclose(file); getchar(); printf("操作完成!n"); system("pause"); system("cls"); } void rankbyeng(stu *head) { char num_tmp[12],name_tmp[25],sex_tmp[8],tmp[50]; int score_eng_tmp,score_com_tmp; stu *i,*j; i=head; while(i!=NULL) { j=i->next; while(j!=NULL) { if(i->score_eng<j->score_eng) { strcpy(num_tmp,i->num); strcpy(name_tmp,i->name); strcpy(sex_tmp,i->sex); score_eng_tmp=i->score_eng; score_com_tmp=i->score_com; strcpy(i->num,j->num); strcpy(i->name,j->name); strcpy(i->sex,j->sex); i->score_eng=j->score_eng; i->score_com=j->score_com; strcpy(j->num,num_tmp); strcpy(j->name,name_tmp); strcpy(j->sex,sex_tmp); j->score_eng=score_eng_tmp; j->score_com=score_com_tmp; } j=j->next; } i=i->next; } } void rankbycom(stu *head) { char num_tmp[12],name_tmp[25],sex_tmp[8],tmp[50]; int score_eng_tmp,score_com_tmp; stu *i,*j; i=head; while(i!=NULL) { j=i->next; while(j!=NULL) { if(i->score_com<j->score_com) { strcpy(num_tmp,i->num); strcpy(name_tmp,i->name); strcpy(sex_tmp,i->sex); score_eng_tmp=i->score_eng; score_com_tmp=i->score_com; strcpy(i->num,j->num); strcpy(i->name,j->name); strcpy(i->sex,j->sex); i->score_eng=j->score_eng; i->score_com=j->score_com; strcpy(j->num,num_tmp); strcpy(j->name,name_tmp); strcpy(j->sex,sex_tmp); j->score_eng=score_eng_tmp; j->score_com=score_com_tmp; } j=j->next; } i=i->next; } } void rankbyall(stu *head) { char num_tmp[12],name_tmp[25],sex_tmp[8],tmp[50]; int score_eng_tmp,score_com_tmp; stu *i,*j; i=head; while(i!=NULL) { j=i->next; while(j!=NULL) { if((i->score_eng+i->score_com)<(j->score_eng+j->score_com)) { strcpy(num_tmp,i->num); strcpy(name_tmp,i->name); strcpy(sex_tmp,i->sex); score_eng_tmp=i->score_eng; score_com_tmp=i->score_com; strcpy(i->num,j->num); strcpy(i->name,j->name); strcpy(i->sex,j->sex); i->score_eng=j->score_eng; i->score_com=j->score_com; strcpy(j->num,num_tmp); strcpy(j->name,name_tmp); strcpy(j->sex,sex_tmp); j->score_eng=score_eng_tmp; j->score_com=score_com_tmp; } j=j->next; } i=i->next; } } void statistics() { char num_tmp[12],name_tmp[25],sex_tmp[8],tmp[50]; int score_eng_tmp,score_com_tmp,select; stu *head=NULL,*p; system("cls"); file=fopen("student.dat","r"); getchar(); fgets(tmp,50,file); while(fscanf(file,"%s %s %s %d %d",num_tmp,name_tmp,sex_tmp,&score_eng_tmp,&score_com_tmp)!=EOF) { p=(stu *)malloc(sizeof(stu)); p->next=head; head=p; strcpy(p->num,num_tmp); strcpy(p->name,name_tmp); strcpy(p->sex,sex_tmp); p->score_eng=score_eng_tmp; p->score_com=score_com_tmp; p=head; } fclose(file); system("cls"); printf("1.按英语成绩排序n"); printf("2.按C语言成绩排序n"); printf("3.按平均成绩排序n"); scanf("%d",&select); switch (select) { case 1: rankbyeng(head); break; case 2: rankbycom(head); break; case 3: rankbyall(head); break; default: printf("输入错误!n"); return; } system("cls"); getchar(); printf("学号t姓名tt性别t英语tC语言n"); while(p!=NULL) { printf("%st%stt%st%dt%dn",p->num,p->name,p->sex,p->score_eng,p->score_com); p=p->next; } system("pause"); system("cls"); } int main() { char select; if(access("student.dat",0)) setnewuser(); if (login()==0) return 0; while(1) { printf("请输入操作序号!n"); printf("1.学生录入n"); printf("2.学生浏览n"); printf("3.学生查询n"); printf("4.学生删除n"); printf("5.数据统计n"); printf("0.退出系统n"); select=getchar(); switch (select) { case '1': insert();break; case '2': view(); break; case '3': find(); break; case '4': del(); break; case '5': statistics(); break; case '0': return 0; default : system("cls"); printf("输入错误!,请重新输入!n"); } } return 0; }
0 条评论
沙发空缺中,还不快抢~