网站大量收购独家精品文档,联系QQ:2885784924

学生基本信息管理的设计与实现.docx

  1. 1、本文档共20页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 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

文档评论(0)

qwd513620855 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档