学生的信息管理系统的C++代码

上传人:鲁** 文档编号:493264768 上传时间:2022-12-03 格式:DOC 页数:25 大小:649KB
返回 下载 相关 举报
学生的信息管理系统的C++代码_第1页
第1页 / 共25页
学生的信息管理系统的C++代码_第2页
第2页 / 共25页
学生的信息管理系统的C++代码_第3页
第3页 / 共25页
学生的信息管理系统的C++代码_第4页
第4页 / 共25页
学生的信息管理系统的C++代码_第5页
第5页 / 共25页
点击查看更多>>
资源描述

《学生的信息管理系统的C++代码》由会员分享,可在线阅读,更多相关《学生的信息管理系统的C++代码(25页珍藏版)》请在金锄头文库上搜索。

1、1.程序执行后的部分效果1.1项目主菜单效果图谙选怪所需墓的操作:I *D : V添一显很 1 2 3 4 5 6 0费i功 所输畀应 涓搽WLP沾口 student. - txl 记事車1.5修改某学生信息2d3兰生馆用、晉理系统-: rH-D住buglSt-u,d.43LDa.添fflf-f _. 1 2 345 6 0息息息息息息统 -一鱼-中一鱼曰一一刁条 学一一睪字 入加曙谊缰 民裤-1腿12 3 4 5 6 0嚣童姓名,性别传业,班如1201强人瓷成 选5S 请请请5?修-101 x|e indent. - txt 记事本1.6查询某学生信息S12A1学生信息晉理系统一一学兰信息育

2、理卒7S-口 :札 rH- D a buglS Lud.43iD添一显很 1 2 3 4 5 6 01.7显示全部学生信息,-1口田a兰生信息省理系统-111 d J 42 2 2i i 1 H -息息息息息息统 xmls.wmrmrl_日卡 学一 一学乎字 录1-显退12 3 4 5 6 0Ltl 2 V rM-JDebng.StiiLd.eiL,tDiL.i.- es c:W8I量 操 的 s 所 圣 迄号 4*ErF?息息息息息息统 兰E 一一R兰3一 _ J亠一豆一一驴卞 - -入加烽酋習 呆添曙 1 3 3 4 5 6 0源代码:/*把StudentData.cpp(源代码)和stu

3、dent.txt( 数据存放处)放在同一个文件夹下*/#in elude #in elude #in elude #in elude #in elude using n amespaee std;/最多提供50个学生的数据,可根据需要进行更改const int MAX = 50;int count = 0;/用来统计学生人数class Stude ntpublic:void Set();/初始化信息,第一次对信息的录入void Add();/添加学生信息/从磁盘读取数据以便进行数据的操作,方便再重写进磁盘frie nd voidRead(stri ngn o,stri ngn ame,stri

4、 ngsex,stri ng special,stri ng clas);int Judge(string num);/判断num是否在学生信息数据库中(注意它有一个参数,并且有一个int型的返回值)void Delete();/删除某学生信息void Chan ge();/修改某学生信息void Search();/查询某学生信息void Display。;/显示全部学生信息private:stri ng m_no;stri ng m_n ame;stri ng m_sex;m_指的是成员变量(member )stri ng m_special;stri ng m_clas;;void St

5、ude nt:Set()stri ng no, n ame, sex, special, clas;ofstream outfile(student.txt);/ 打开文件if(!outfile)cerr ope n errore ndl;exit(1);/退出程序 coutvv 当学号输入为0时,停止输入!endl;cout请依次输入学生的学号,姓名,性别,专业,班级:endl;for(i nt i=0; iMAX; i+)cout第count+1个学生:specialclas;coun t+;m_no = no;/每录入一个学号,写进磁盘保outfilem_ no vvt;存,以下同理m_

6、n ame = n ame; outfilem_ namevt;m_sex = sex;outfilevm_sexvt;m_special = special;outfilem_specialvvt;m_clas = clas;outfilem_clase ndl;outfile.close();/添加学生信息void Stude nt:Add()stri ng no, n ame, sex, special, clas;/以追加的方式录入信息,直接将信息追加到以前文件的末尾ofstream outfile(stude nt.txt,ios:app);if(!outfile)cerr ope

7、n errore ndl;exit(1);count+;/添加一个学生信息,当然 count 要 +1coutvv请依次输入要添加的学生学号,姓名,性别,专业,班级:sexspecialclas;m_no = no;outfilem_ no vvt;m_n ame = n ame;outfilem_ namevt;m_sex = sex;outfilevm_sexvt;m_special = special;outfilem_specialvvt;m_clas = clas;outfilem_clase ndl;outfile.close();cout已添加成功!endl;/从磁盘读取数据se

8、x,stri ngvoid Read(stri ngn o,stri ngn ame,stri ngspecial,stri ng clas)ifstream in file(stude nt.txt,ios:i n);if(!i nfile)cerr ope n errore ndl;exit(1);for(int i=0; i n oi n ameisexispecialiclasi;in file.close();/判断某学号的学生是否在数据库中int Stude nt:Judge(stri ng num)stri ngnoMAX,n ameMAX,sexMAX, specialMAX,

9、clasMAX;/调用Read()函数,获Read( no, n ame, sex, special, clas);取数据,以便等下进行相关数据的判断for(int i=0; icount; i+)if(num = n oi)return i;/如果存在,返回其下标break;return -1;/ 否则,返回-1/删除某学生信息void Stude nt:Delete()stri ng num, noMAX,n ameMAX,sexMAX,specialMAX, clasMAX;Read(no, name, sex, special, clas);/ 读取学生所有数据,coutvv请输入你要删除的学生学号cinnum;int k = Judge( nu m);/定义一个k来接收Judge()的返回值,等下用来判断该num是否存在if(k != -1)/如果k不等于-1,表示要删除的学生存在 ofstream outfile(stude nt.txt);if(!outfile)cerr ope n errore ndl; exit(1

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 活动策划

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号