C++程序实验报告.docx_第1页
C++程序实验报告.docx_第2页
C++程序实验报告.docx_第3页
C++程序实验报告.docx_第4页
C++程序实验报告.docx_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

计算机学院11级C+程序实验报告C+课程设计报告题 目:学生信息管理系统设 计 者: 陈金雷专业班级:物联网1班学 号:2011302873指导教师: 郝老师 2012年 6 月 14 日安徽理工大学计算机学院30安徽理工大学课程设计任务书21 题目与要求31.1问题提出31.2 本系统涉及的知识点41.3 功能要求41.4问题分析42 功能设计52.1显示界面52.2 部分模块流程图63 程序代码设计64 C+程序设计总结295 结束语29指导教师评价29安徽理工大学课程设计任务书 计算机科学与工程学院 硬件 教研室学 号2011302873学生姓名陈金雷专业(班级) 物联网工程(1)班设计题目学生信息管理系统设计技术参数1 熟悉C+语言的编程方法 2 初步了解MFC的使用方法 设计要求题目的选择是根据C+语言的特点主要针对C+初学者而设计的,是对学生所学课程知识较为全面的考察。 由于C+语言编程相对其他语言编程比较复杂,因此,在设计上应把重点放在程序的功能实现上,不要太在意程序的结构和显示界面的设计。不要局限于题目所规定的要求,可以灵活裁减,设计出功能更完善的程序。 工作量完成所选题目的程序设计;课程设计说明书工作计划第1次熟悉软件环境。第2次绘制程序流程图。第3次用编写程序。第4次用调试运行程序。第5次编写课程设计说明书参考资料Visual C+面向对象程序设计教程与实验,温秀梅、丁学钧主编,第二版,北京:清华大学出版社,2009.4 1 题目与要求1.1问题提出学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。试设计一学生信息管理系统,使之能提供以下功能:系统以菜单方式工作,学生信息录入功能(学生信息用文件保存)输入学生信息浏览功能,输出查询排序功能算法按学号查询按姓名查询学生信息的删除与修改1.2 本系统涉及的知识点结构、指针、循环、数组、函数、宏定义1.3 功能要求1、录入学生信息,每个学生的信息包括:学号、姓名、性别、班级、手机号、邮箱号;2、查询学生信息;3、排序:分别按平均分排序、按学号排序;4、根据学号查询成绩;5、修改学生信息;1.4问题分析定义不同的函数,实现信息管理系统各项功能。其中,学生信息包括:学号,姓名,年龄,性别,出生年月,地址,电话,E-mail等。实现功能包括:学生信息录入功能,学生信息浏览功能,查询,排序功能,按学号查询,学生信息的删除与修改等。2 功能设计2.1显示界面2.2 部分模块流程图学生信息管理系统系统帮助说明输入学生信息查询学生信息修改学生信息增加学生信息删除学生信息保存学生信息3 程序代码设计头文件:#include stdafx.h#include /*I/o函数*/#include /*其他说明*/#include#includeusing namespace std;#include#include #define LEN 30 /*学号和姓名最大学生人数*/#define N 100 /*最大学生人数*/struct student /*声明函数体*/ char code20; /*学号*/ char name10; /*姓名*/ int age; /*年龄*/ char sex5; /*性别*/ char time20; /*出生年月*/ char add20; /*家庭地址*/ char tel20; /*电话*/ char mail20; /*邮箱地址*/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 *);student *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); system(cls); cout请按任意键进入主菜单!endl; system(cls); head=caidan_information(head); system(pause); return 0; 系统帮助说明函数:student *help_information(student *head)system(COLOR 3f); coutn 尊敬的用户您好!endl; / coutn = | endl; |);coutn 1.欢迎进入帮助系统! endl; cout endl; cout 2.请按照菜单提示进入数字代号! endl; cout 3.增加学生信息后,请切记保存! endl; cout 4.谢谢您的使用! endl; cout = ;return(head);学生信息输入函数:student *shuru_information(student *head) /* 实现录入学生基本信息功能 */ int i,flag=1; while(flag) flag=0; cout请输入需要创建信息的学生人数(1-100):endl; scanf(%d,&n); if(n100) flag=1; cout输入错误,检查后请重新输入!endl; for(i=0;in;i+) cout请输入第%d个学生的基本信息:ni+1; coutstui.code; ; getchar(); coutstui.sex; coutstui.age; coutstui.time; coutstui.add; coutstui.tel; coutstui.mail; cout录入完毕!n; head=baocun_information(head);return(head);student *baocun_information(student *head) /*保存学生信息到文件的函数*/ int i; FILE *fp; if(fp=fopen(student.txt,wb)=NULL) /*创建文件并判断是否能够打开成功*/ cout文件不能打开!n; exit(0); /*如果不能打开文件,则关闭当前所有的文件*/ for(i=0;in;i+) /*将内存中的学生信息写入到磁盘文件中*/ if(fwrite(&stui,sizeof(struct student),1,fp)!=1) cout文件输入错误!n; fclose(fp); return(head);学生信息查询:student *chaxun_information(student *head) int i,t,flag; char s130; system(COLOR 5f); coutn =n; cout | 1.按学号查询 |n; cout | 2.按姓名查询 |n; cout | 3.退出本菜单 |n; cout =n;while(1) flag=0; coutt; switch(t) case 1: couts1; for(i=0;in;i+) if(strcmp(stui.code,s1)=0) flag=1; cout学生学号 ;cout stui.code; coutn学生姓名 ; ; coutn年龄 ; coutstui.age; coutn性别 ;coutstui.sex; coutn出生年月 ; coutstui.time; coutn家庭地址 ; coutstui.add; coutn电话 ; coutstui.tel; coutnE-mail ; coutstui.mail; if(flag=0) cout该学号不存在! n;break;case 2: couts1; for(i=0;in;i+) if(strcmp(,s1)=0) flag=1; cout学生学号 学生姓名 年龄 性别 出生年月 家庭地址 电话 E-mail n; cout=n; cout%6s %7s %6d %5s %9s %8s %10s %14sn, stui.code,,stui.age,stui.sex,stui.time,stui.add,stui.tel,stui.mail; if(flag=0) cout该姓名不存在!n;break;case 3: return (head); default: cout请在1-3之间选择n; return(head);修改学生信息:student *xiugai_information(student *head) int i,t,num; char sex13,s130,s230; couts1; for(i=0;in;i+) if(strcmp(stui.code,s1)=0) num=i; system(COLOR 4f); cout =n; cout | 1.修改姓名 |n; cout | 2.修改年龄 |n; cout | 3.修改性别 |n; cout | 4.修改出生年月 |n; cout | 5.修改地址 |n; cout | 6.修改电话号码 |n; cout | 7.修改E-mail |n; cout | 8.修改退出本菜单 |n; cout =n; while(1) coutt; switch(t) case 1: couts2; strcpy(,s2);break; case 2: couts2; cinstunum.age;break; case 3: case 4: couts2; strcpy(stunum.time,s2);break; case 5: couts2; strcpy(stunum.add,s2);break; case 6:couts2; strcpy(stunum.tel,s2);break; case 7: couts2; strcpy(stunum.mail,s2);break; case 8: return (head); default: cout请在1-8之间选择n; return(head); 对学生信息进行排序:student *paixu_information(student *head) int i,j,*p,*q,s; char temp10; for(i=0;ii;j-) if(strcmp(stuj-1.code,stuj.code)0) strcpy(temp,stuj-1.code); strcpy(stuj-1.code,stuj.code); strcpy(stuj.code,temp); strcpy(temp,); strcpy(,); strcpy(,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.add); 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_information(student *head) int i=n,j,flag; coutm; do flag=1; while(flag) flag=0; cout请输入第%d个学生的学号:nstui.code; for(j=0;ji;j+) if(strcmp(stui.code,stuj.code)=0) cout该学号已经存在,请仔细核查后重新输入!n; flag=1;break; cout请输入第%d个学生的学生姓名:; cout请输入第%d个学生的学生年龄:nstui.age; cout请输入第%d个学生的学生性别:; cout请输入第%d个学生的学生出生年月:(格式:年,月,日)nstui.time; cout请输入第%d个学生的学生家庭地址:nstui.add; cout请输入第%d个学生的学生电话:nstui.tel; cout请输入第%d个学生的学生E-mail:nstui.mail;if(flag=0) i+; while(in+m); n=n+m; cout输入完毕!nn;head=paixu_information(head);return(head);删除学生信息:student *shanchu_information(student *head) int i,j,flag=0; char s115; couts1; for(i=1;in;i+) if(strcmp(stui.code,s1)=0) flag=1; for(j=i;jn-1;j+) stuj=stuj+1; if(flag=0) cout该学号不存在!n;if(flag=1) cout删除成功!显示结果请按6!n; n-;return(head);student *xianshi_information(student *head) int i; FILE *fp; if(fp=fopen(student.txt,rb)=NULL) cout打开文件时错误!请按任意键退出!; system(pause); exit(0); cout 所有学生的信息为:n n; cout学生学号 学生姓名 年龄 性别 出生年月 家庭地址 电话 E-mail ; cout=; for(i=0;in;i+) fread(&stui,sizeof(struct student),1,fp); cout%6s %7s %6d %5s %9s %8s %10s %14sn stui.code,,stui.age,stui.sex,stui.time,stui.add,stui.tel,stui.mail;return(head);退出系统:student *tuichuxitong_information(student *head) system(COLOR 3f); cout -【学生信息管理系统】-n; coutn; coutn; cout 指导老师:郝伟 n; cout=n; cout Bye-Byen; coutn; cout n; coutn; cout n; cout n; coutn; cout n; cout 安 物 n; cout 徽 联 n; cout 理 网 n; cout 工 工 n; cout 大 工 n; cout 学 程 n; cout 一 n; cout 班 n; cout 谢谢使用n;return(head);显示主界面:student *huanyingyemian_information(student *head) system(COLOR 6f); coutn; coutn; coutn; cout-安徽理工大学-n; coutn; coutn; coutn; coutn; coutn; cout 尊敬的用户:您好!n; coutn; coutn; cout 欢迎使用n; coutn; coutn; cout -【学生信息管理系统】-n; coutn;return(head);student *caidan_information(student *head) int num; system(COLOR 1f); coutnn 物联网11级学生信息管理系统nn; cout=n; cout =指导老师:郝伟=n; coutn; cout =系统功能菜单=n; cout =友情提醒:查询前请刷新系统!=n; cout =n; cout |=|n; cout | 0.系统帮助说明 1.输入学生信息 |n; cout |-|n; cout | 2.查询学生信息 3.修改学生信息 |n; cout |-|n; cout | 4.增加学生信息 5.按学号删信息 |n; cout |-|n; cout | 6.显示当前信息 7.保存当前信息 |n; cout |-|n; cout | 8.退出系统 |n; cout |=|n; cout =n; coutnum; switch(num) case 0:system(cls);head=help_information(head);break; case 1:system(cls);head=shuru_information(head);

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论