- 1、本文档共20页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
学生基本信息管理的设计与实现
//student.h#includeiostream#includestring#includefstreamusing namespace std;const int MaxSize=10;const int Sco_num=3;struct Score{string grade;float English,Math,Physics;Score *link;Score():English(0.0),Math(0.0),Physics(0.0),link(NULL){}Score(string gra,float eng,float mat,float phy):grade(gra),English(eng),Math(mat),Physics(phy),link(NULL){}friend ostream operator(ostream os,Score *p){if(p==NULL){osWrong Pointer.endl;return os;}else{osGrade p-grade :p-English p-Math p-Physicsendl;p=p-link;return os;}}};struct Info{string Num,Name,Sex,Birthday;Score *first;Info(){first =new Score;}friend ostream operator(ostream os,Info info){osinfo.Num info.Name info.Sex info.Birthdayendl;return os;}};class Student{public: Student():Stu_num(0),eng(0.0),mat(0.0),phy(0.0){inf=new Info[MaxSize];}bool search(string s);bool locate(string s,Info info);bool insert(ifstream is); //文件流插入学生信息bool insert(string num,string name,string sex,string birth);//插入学生基本信息bool insert(string num,string grade,float eng,float mat,float phy);//插入学生成绩bool insert(string num,string name,string sex,string birth,string grade,float eng,float mat,float phy);//插入学生全部信息bool see(string s); // 查找并输出学号s的学生的全部信息bool see(string s1,string s2); //查找并输出学号s1的学生s2学期的信息bool remove(string s); //删除学号s学生的全部信息void average(string s); //输入学号为s的学生的各学期平均成绩void average(string s1,string s2); //输入学号为s1的学生s2学期平均成绩 void wt(); //将数据写入文件friend ostream operator(ostream os,Student stu)//重载输出流{for(int i=0;i!=stu.Stu_num;++i){Score *current=stu.inf[i].first-link;osstu.inf[i];while(current!=NULL){oscurrent;current=current-link;}}return os;}protected:int Stu_num; //数组中元素个数Info *inf; //建立结构体数组string num,name,sex,birth,grade; //交换数据float eng,mat,phy;};2.主要函数实现代码bool Student::locate(string s,Info info) //定位s学号学生信息,由info返回{int test=0;for(int i=0;i!=Stu_num;++i){if(s==inf[i].Num){info=inf[i];test=1;return true;}}return false;}重载多个insert函数 实现插入或修改学生基本信息,成绩,所有信息bool Student::insert(ifstream is)//有从文件流中读取信息创建结构体数组和链表{isnumnamesexbirthgradeengmatphy;i
您可能关注的文档
- 2012中考数学基础题强化提高测试6.doc
- 新的毕业论文评审表.doc
- 信息安全基础样卷.doc
- 2012年伦理学及社会哲学部分复习纲要.doc
- 概率统计07.12.doc
- 3.2计划与活动.ppt
- 小机维护文档(开机、关机).doc
- 温宿一中集资建房方案.doc
- 带电粒子在电场中运动题型训练.doc
- 最新大学英语四级考试介绍.doc
- 新高考生物二轮复习讲练测第6讲 遗传的分子基础(检测) (原卷版).docx
- 新高考生物二轮复习讲练测第12讲 生物与环境(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第3讲 酶和ATP(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第9讲 神经调节与体液调节(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第11讲 植物生命活动的调节(讲练)(原卷版).docx
- 新高考生物二轮复习讲练测第8讲 生物的变异、育种与进化(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第5讲 细胞的分裂、分化、衰老和死亡(讲练)(原卷版).docx
- 新高考生物二轮复习讲练测第5讲 细胞的分裂、分化、衰老和死亡(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第12讲 生物与环境(讲练)(原卷版).docx
- 新高考生物二轮复习讲练测第11讲 植物生命活动的调节(检测)(原卷版).docx
文档评论(0)