2016-06-13
展开全部
参考下:#include#include#include#defineSTU_NUM10#defineSTU_NAME_LEN20#defineSTU_NO_LEN10#defineSTU_SEX_LEN6usingnamespacestd;classStudent{public:voidinitStuInfo();//初始化学生信息voidaddStuInfo();//添加学生信息voidmodifyStyInfo();//更改学生信息voidsearchStuInfo();//查询学生信息voiddeleteStuInfo();//删除学生信息voidprintStuInfo();//打印学生信息private:charsno[STU_NO_LEN];charstuName[STU_NAME_LEN];charsex[STU_SEX_LEN];intage;};voidStudent::initStuInfo(){ofstreamoutfile;outfile.open("stuInfo",ios::trunc);if(!outfile){cout>sno;cout>stuName;cout>sex;cout>age;outfileinputName;while(!infile.eof()){infile>>sno>>stuName>>sex>>age;if(infile.fail()){break;}if(strcmp(inputName,stuName)==0){coutinputName;ifstreaminfile;infile.open("stuInfo",ios::in);if(!infile){cout>sno>>stuName>>sex>>age;if(infile.fail()){break;}if(strcmp(inputName,stuName)==0){break;}else{strcpy(stNo[count],sno);strcpy(stName[count],stuName);strcpy(stSex[count],sex);stAge[count]=age;}count++;}infile.close();ifstreaminfile2;infile2.open("stuInfo",ios::in);if(!infile2){cout>sno>>stuName>>sex>>age;if(infile2.fail()){break;}if(curCount==count){curCount++;continue;}if(curCount>count){strcpy(stNo[curCount-1],sno);strcpy(stName[curCount-1],stuName);strcpy(stSex[curCount-1],sex);stAge[curCount-1]=age;}curCount++;}infile2.close();initStuInfo();//初始化//重新写入文件ofstreamoutfile;outfile.open("stuInfo",ios::app);if(!outfile){cout>inputName;ifstreaminfile;infile.open("stuInfo",ios::in);if(!infile){cout>sno>>stuName>>sex>>age;if(infile.fail()){break;}count++;if(strcmp(inputName,stuName)==0){cout>stNo[count-1];cout>stName[count-1];cout>stSex[count-1];cout>stAge[count-1];break;}else{strcpy(stNo[count-1],sno);strcpy(stName[count-1],stuName);strcpy(stSex[count-1],sex);stAge[count-1]=age;}}infile.close();ifstreaminfile2;infile2.open("stuInfo",ios::in);if(!infile2){cout>sno>>stuName>>sex>>age;if(infile2.fail()){break;}curCount++;if(curCount>count){strcpy(stNo[curCount-1],sno);strcpy(stName[curCount-1],stuName);strcpy(stSex[curCount-1],sex);stAge[curCount-1]=age;}}infile2.close();initStuInfo();//初始化//重新写入文件ofstreamoutfile;outfile.open("stuInfo",ios::app);if(!outfile){cout>sno>>stuName>>sex>>age;if(infile.fail()){break;}coutnum;switch(num){case1:stu.initStuInfo();break;case2:stu.addStuInfo();break;case3:stu.modifyStyInfo();break;case4:stu.deleteStuInfo();break;case5:stu.searchStuInfo();break;case6:stu.printStuInfo();break;default:cout<<"输入不符合规则"<
享知信息
2023-10-16 广告
2023-10-16 广告
上海享知信息科技有限公司的敏捷开发需求管理工具旨在提高项目效率。该工具采用易于理解的简明语言,允许团队成员轻松共享、讨论和管理需求。它支持灵活的需求变更,可帮助团队实时响应并跟踪项目进展。同时,工具的分层结构使得需求与设计、代码相关联,为整...
点击进入详情页
本回答由享知信息提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询