1、不要局限于题目所规定的要求,可以灵活裁减,设计出功能更完善的程序。工作量完成所选题目的程序设计;课程设计说明书工作计划第1次熟悉软件环境。第2次绘制程序流程图。第3次用编写程序。第4次用调试运行程序。第5次编写课程设计说明书参考资料Visual C+面向对象程序设计教程与实验,温秀梅、丁学钧主编,第二版,北京:清华大学出版社,2009.4 1 题目与要求1.1问题提出学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:系统以菜单方式工作,学生信息录入功能(学生信息用文件保存)输入学生信息浏览功能,输出查询排序功能算法按学号查
2、询按姓名查询学生信息的删除与修改1.2 本系统涉及的知识点结构、指针、循环、数组、函数、宏定义1.3 功能要求1、录入学生信息,每个学生的信息包括:学号、姓名、性别、班级、手机号、邮箱号;2、查询学生信息;3、排序:分别按平均分排序、按学号排序;4、根据学号查询成绩;5、修改学生信息;1.4问题分析定义不同的函数,实现信息管理系统各项功能。其中,学生信息包括:实现功能包括:学生信息录入功能,学生信息浏览功能,查询,排序功能,按学号查询,学生信息的删除与修改等。2 功能设计2.1显示界面2.2 部分模块流程图3 程序代码设计头文件:#include stdafx.h#include /*I/o函
3、数*/stdlib.h /*其他说明*/string.hiostreamusing namespace std;conio.hiomanip#define LEN 30 /*学号和姓名最大学生人数*/#define N 100 /*最大学生人数*/struct student /*声明函数体*/ char code20; /*学号*/ char name10; /*姓名*/ int age; /*年龄*/ char sex5; /*性别*/ char time20; /*出生年月*/ char add20; /*家庭地址*/ char tel20; /*电话*/ char mail20; /*
4、邮箱地址*/stuN;int k=1,m,n;student *shuru_information(student *);student *chaxun_information(student *);student *xiugai_information(student *);student *zengjia_information(student *);student *shanchu_information(student *);student *xianshi_information(student *);student *baocun_information(student *);st
5、udent *caidan_information(student *);student *tuichuxitong_information(student *);student *huanyingyemian_information(student *);student *help_information(student *);student *paixu_information(student *);主函数:int main() student *head; while(k) head=huanyingyemian_information(head); system(pause);cls
6、cout请按任意键进入主菜单!endl; head=caidan_information(head); return 0;系统帮助说明函数:student *help_information(student *head)COLOR 3fn 尊敬的用户您好! / coutn = | |coutn 1.欢迎进入帮助系统! 2.请按照菜单提示进入数字代号! 3.增加学生信息后,请切记保存! 4.谢谢您的使用! = ; return(head);学生信息输入函数:student *shuru_information(student *head) /* 实现录入学生基本信息功能 */ int i,fla
7、g=1; while(flag) flag=0;请输入需要创建信息的学生人数(1-100): scanf(%d,&n); if(n100) flag=1;输入错误,检查后请重新输入!endl; for(i=0;istui.code;请输入姓名:stui.name; getchar();请输入性别(男,女):stui.sex;请输入年龄:stui.age;请输入出生年月(输入格式:年.月):stui.time;请输入家庭地址:stui.add;请输入电话号码:stui.tel;请输入E-mail地址:stui.mail;录入完毕! head=baocun_information(head);st
8、udent *baocun_information(student *head) /*保存学生信息到文件的函数*/ int i; FILE *fp; if(fp=fopen(student.txt,wb)=NULL) /*创建文件并判断是否能够打开成功*/文件不能打开! exit(0); /*如果不能打开文件,则关闭当前所有的文件*/i+) /*将内存中的学生信息写入到磁盘文件中*/ if(fwrite(&stui,sizeof(struct student),1,fp)!=1)文件输入错误! fclose(fp);学生信息查询:student *chaxun_information(stud
9、ent *head) int i,t,flag; char s130;COLOR 5fn =n | 1.按学号查询 |n | 2.按姓名查询 |n | 3.退出本菜单 |n =nwhile(1) 请输入子菜单编号:cint; switch(t)case 1: 请输入要查询的学生的学号: ns1; if(strcmp(stui.code,s1)=0)学生学号 stui.code;n学生姓名 n年龄 n性别 n出生年月 n家庭地址 n电话 nE-mail if(flag=0)该学号不存在!break;case 2: 请输入要查询的学生的姓名: if(strcmp(stui.name,s1)=0)学
10、生学号 学生姓名 年龄 性别 出生年月 家庭地址 电话 E-mail n=n%6s %7s %6d %5s %9s %8s %10s %14sn, stui.code,stui.name,stui.age,stui.sex,stui.time,stui.add,stui.tel,stui.mail;该姓名不存在!case 3: return (head); default:请在1-3之间选择nreturn(head);修改学生信息:student *xiugai_information(student *head) int i,t,num; char sex13,s130,s230; num=
11、i;COLOR 4f =n | 1.修改姓名 |n | 2.修改年龄 |n | 3.修改性别 |n | 4.修改出生年月 |n | 5.修改地址 |n | 6.修改电话号码 |n | 7.修改E-mail |n | 8.修改退出本菜单 |n while(1)请输入子菜单的编号: case 1:请输入新的姓名:s2; strcpy(stunum.name,s2); case 2:请输入新的年龄:stunum.age; case 3: case 4:请输入新的出生年月: strcpy(stunum.time,s2);break; case 5:请输入新的地址: strcpy(stunum.add,
12、s2); case 6:请输入新的电话号码: strcpy(stunum.tel,s2); case 7:请输入新的E-mail: strcpy(stunum.mail,s2); case 8:请在1-8之间选择n return(head);对学生信息进行排序:student *paixu_information(student *head) int i,j,*p,*q,s; char temp10;n-1; for(j=n-1;ji;j-) if(strcmp(stuj-1.code,stuj.code)0) strcpy(temp,stuj-1.code); strcpy(stuj-1.c
13、ode,stuj.code); strcpy(stuj.code,temp); strcpy(temp,stuj-1.name); strcpy(stuj-1.name,stuj.name); strcpy(stuj.name,temp); strcpy(temp,stuj-1.sex); strcpy(stuj-1.sex,stuj.sex); strcpy(stuj.sex,temp); strcpy(temp,stuj-1.time); strcpy(stuj-1.time,stuj.time); strcpy(stuj.time,temp); strcpy(temp,stuj-1.ad
14、d); strcpy(stuj-1.add,stuj.add); strcpy(stuj.add,temp); strcpy(temp,stuj-1.tel); strcpy(stuj-1.tel,stuj.tel); strcpy(stuj.tel,temp); strcpy(temp,stuj-1.mail); strcpy(stuj-1.mail,stuj.mail); strcpy(stuj.mail,temp); p=&stuj-1.age; q=&stuj.age; s=*p; *p=*q; *q=s; return(head);增加学生信息:student *zengjia_in
15、formation(student *head) int i=n,j,flag;请输入将要增加的学生数目:m; do请输入第%d个学生的学号: for(j=0;jj+) if(strcmp(stui.code,stuj.code)=0)该学号已经存在,请仔细核查后重新输入!请输入第%d个学生的学生姓名:请输入第%d个学生的学生年龄:请输入第%d个学生的学生性别:请输入第%d个学生的学生出生年月:(格式:年,月,日)n请输入第%d个学生的学生家庭地址:请输入第%d个学生的学生电话:请输入第%d个学生的学生E-mail:if(flag=0) i+; while(in+m); n=n+m;输入完毕!
16、nnhead=paixu_information(head);删除学生信息:student *shanchu_information(student *head) int i,j,flag=0; char s115;请输入将要删除的学生的学号: for(i=1; for(j=i; stuj=stuj+1;if(flag=1)删除成功!显示结果请按6! n-;return(head);student *xianshi_information(student *head)rb)=NULL)打开文件时错误!请按任意键退出! 所有学生的信息为:n n学生学号 学生姓名 年龄 性别 出生年月 家庭地址
17、电话 E-mail =i+) fread(&stui,sizeof(struct student),1,fp); stui.code,stui.name,stui.age,stui.sex,stui.time,stui.add,stui.tel,stui.mail;退出系统:student *tuichuxitong_information(student *head) system( -【学生信息管理系统】-n 指导老师:郝伟 n Bye-Byen n n n 安 物 n 徽 联 n 理 网 n 工 工 n 大 工 n 学 程 n 一 n 班 n 谢谢使用n显示主界面:student *huanyingyemian_information(student *head) system(COLOR 6f
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1