C++学生管理系统代码(共34页).doc

上传人:飞****2 文档编号:13476144 上传时间:2022-04-29 格式:DOC 页数:34 大小:53KB
返回 下载 相关 举报
C++学生管理系统代码(共34页).doc_第1页
第1页 / 共34页
C++学生管理系统代码(共34页).doc_第2页
第2页 / 共34页
点击查看更多>>
资源描述

《C++学生管理系统代码(共34页).doc》由会员分享,可在线阅读,更多相关《C++学生管理系统代码(共34页).doc(34页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、精选优质文档-倾情为你奉上#include #include #include #include #include #include usingnamespacestd; constintNAME_NUM=30; structstudent charnameNAME_NUM; floatnum; floatchinaNum; floatenglishNum; floatmathNum; floataverage; floatresult; intpos; student*next; ; voidPrint(student*head); voidInsertFront(student*&head

2、,student*pNew); voidInsertRear(student*&head,student*pNew); student*Find(student*head,char*findStr,chartype); student*Read(); voidWrite(student*head); voidShowList(student*head); intGetLength(student*head); voidDelete(student*&head,char*delStr,intdelNum); voidFindMaxOrMin(student*head,chartype,charm

3、axOrMin); voidReword(student*pStd); voidSort(student*&head,chartype,charmaxOrMin); voidCount(student*&head); voidDeleteAll(student*&head); boolEnter(chartype); voidSetTitle(boolisLoad); voidAboutMe(); voidChaXun(stringstr,student*head); voidPaiMing(stringstr,student*head); voidShanChu(stringstr,stud

4、ent*&head); voidXianShi(stringstr,student*head); voidXuiGai(stringstr,student*&head); voidZengJia(stringstr,student*&head); intRun(); boolEnter(chartype) ofstreamout(Password.pwd,ios:app); ifstreamin(Password.pwd); strings2; intnum=0; stringzhangHao; stringmiMa; while(!in.eof() insnum; num+; if(num=

5、2) break; if(pare()=0|type=2) if(pare()=0&type!=2) cout你是第一次使用本程序,请设置帐号和密码.endl; else boolisLoad=false; isLoad=Enter(1); if(isLoad=true) cout修改用户.endl; out.close(); out.open(Password.pwd,ios:trunc); else cout你输入的密码错误.endl; cout你不是管理员不能修改密码.endl; returnfalse; couts0; couts1; strings1,s2; for(inti=0;i

6、s0.size();i+) s1+=char(int(s0i)+11); for(i=0;is1.size();i+) s2+=char(int(s1i)+11); s0=s1; s1=s2; for(i=0;i=1;i+) outsi; out.close(); strings1,s2; for(inti=0;is0.size();i+) s1+=char(int(s0i)-11); for(i=0;is1.size();i+) s2+=char(int(s1i)-11); coutzhangHao; coutmiMa; if(zhangHpare(s1)=0&miMpare(s2)=0)

7、returntrue; else returnfalse; returnfalse; voidPrint(student*head) student*pHead=head; intnum=strlen(head-name); while(head) if(numname) num=strlen(head-name); head=head-next; head=pHead; coutsetw(num)namesetw(8) numsetw(10)chinaNum setw(10)mathNumsetw(10) englishNumsetw(8)result setw(8)averagesetw(

8、5)posendl; voidShowList(student*head) cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(6)名次:endlnext; coutnext; out.close(); student*Read() ifstreamin(Student.dat); student*head; student*pP; student*pEnd; pP=newstudent; pEnd=head=pP; student*pS=newstudent; memset

9、(pS-name,0,NAME_NUM); in.read(char*)pS,sizeof(student); if(strcmp(pS-name,0)=0) returnNULL; strcpy(pP-name,pS-name); pP-num=pS-num; pP-chinaNum=pS-chinaNum; pP-englishNum=pS-englishNum; pP-mathNum=pS-mathNum; while(!in.eof() in.read(char*)pS,sizeof(student); pEnd-next=pP; pEnd=pP; pP=newstudent; str

10、cpy(pP-name,pS-name); pP-num=pS-num; pP-chinaNum=pS-chinaNum; pP-englishNum=pS-englishNum; pP-mathNum=pS-mathNum; pEnd-next=NULL; deletepP; returnhead; student*Find(student*head,char*findStr,chartype) /*参数说明: type=1按名字查找 type=2按座号查找 type=3按语文查找 type=4按数学查找 type=5按英语查找 type=6按总分查找 type=7按平均分查找 type=8

11、按排名查找/没有实现 */ boolisFind=false; student*firstStd=NULL; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(5)名次:endlname,findStr)=0) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=2) if(int(head-num)=int(ato

12、f(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=3) if(int(head-chinaNum)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=4) if(int(head-mathNum)=int(atof(f

13、indStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=5) if(int(head-englishNum)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=6) if(int(head-result)=int(atof(fin

14、dStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=7) if(int(head-average)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; elseif(type=8) if(int(head-pos)=int(atof(findStr) if

15、(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) returnfirstStd; head=head-next; if(isFind=false) cout找不到你要找的记录.next=NULL) break; head=head-next; strcpy(pS-name,pNew-name); pS-num=pNew-num; pS-chinaNum=pNew-chinaNum; pS-englishNum=pNew-englishNum; pS-mathNum=pNew-mathNum;

16、pS-next=NULL; pEnd-next=pS; head=pHead; voidInsertFront(student*&head,student*pNew) student*pHead=newstudent; strcpy(pHead-name,pNew-name); pHead-num=pNew-num; pHead-chinaNum=pNew-chinaNum; pHead-englishNum=pNew-englishNum; pHead-mathNum=pNew-mathNum; pHead-next=head; head=pHead; intGetLength(studen

17、t*head) intlen=0; while(head) len+; head=head-next; returnlen; voidDelete(student*&head,char*delStr,intdelNum) student*pDel,*pNew,*pHead; boolisFind=false; pHead=head; if(strcmp(head-name,delStr)=0) pNew=head-next; deletehead; head=pNew; if(delNum=2) coutendl因为要删除的记录在前面,所有只删除第一记录.next) if(delNum=2)

18、if(strcmp(head-next-name,delStr)=0) pNew=head-next-next; pDel=head-next; deletepDel; head-next=pNew; head=pHead; isFind=true; else if(strcmp(head-next-name,delStr)=0) pNew=head-next-next; pDel=head-next; deletepDel; head-next=pNew; head=pHead; return; head=head-next; head=pHead; if(isFind=false) cou

19、t找不到你要删除的记录.endl; else cout删除记录成功.chinaNum); elseif(type=2) maxNum=int(head-mathNum); elseif(type=3) maxNum=int(head-englishNum); elseif(type=4) maxNum=int(head-result); elseif(type=5) maxNum=int(head-average); elseif(type=6) maxNum=head-pos; else cout你输入错误,请重新输入.endl; return; while(head) if(maxOrMi

20、n=1) if(type=1) if(maxNumchinaNum) maxNum=int(head-chinaNum); elseif(type=2) if(maxNummathNum) maxNum=int(head-mathNum); elseif(type=3) if(maxNumenglishNum) maxNum=int(head-englishNum); elseif(type=4) if(maxNumresult) maxNum=int(head-result); elseif(type=5) if(maxNumaverage) maxNum=int(head-average)

21、; elseif(type=6) if(maxNumpos) maxNum=head-pos; else if(type=1) if(maxNumint(head-chinaNum) maxNum=int(head-chinaNum); elseif(type=2) if(maxNumint(head-mathNum) maxNum=int(head-mathNum); elseif(type=3) if(maxNumint(head-englishNum) maxNum=int(head-englishNum); elseif(type=4) if(maxNumint(head-result

22、) maxNum=int(head-result); elseif(type=5) if(maxNumint(head-average) maxNum=int(head-average); elseif(type=6) if(maxNumhead-pos) maxNum=head-pos; head=head-next; head=pHead; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10)数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(5)名次:endlchinaNum)=maxNum) Print(head);

23、elseif(type=2) if(int(head-mathNum)=maxNum) Print(head); elseif(type=3) if(int(head-englishNum)=maxNum) Print(head); elseif(type=4) if(int(head-result)=maxNum) Print(head); elseif(type=5) if(int(head-average)=maxNum) Print(head); elseif(type=6) if(head-pos=maxNum) Print(head); head=head-next; voidRe

24、word(student*pStd) if(pStd!=NULL) cout请输入学生的新名字:pStd-name; cout请输入学生的座号pStd-num; cout请输入学生的语文分数pStd-chinaNum; cout请输入学生的数学分数pStd-mathNum; cout请输入学生的英语分数pStd-englishNum; else return; voidSort(student*&head,chartype,charmaxOrMin) /*参数说明: type=1按语文排列 type=2按数学排列 type=3按英语排列 type=4按总分排列 type=5按平均分排列 typ

25、e=6按座号排列 */ student*pHead,*pH; pHead=pH=head; intlen=GetLength(head); float*array=newfloatlen; inti; intx=0; floatnum=0; while(head) Count(head); if(type=1) num=head-chinaNum; elseif(type=2) num=head-mathNum; elseif(type=3) num=head-englishNum; elseif(type=4) num=head-result; elseif(type=5) num=head

26、-average; elseif(type=6) num=head-num; arrayx=num; x+; head=head-next; head=pHead; if(maxOrMin=1) for(i=1;ilen;i+) for(intj=0;jlen-i;j+) if(arrayjarrayj+1) floatnum; num=arrayj; arrayj=arrayj+1; arrayj+1=num; else for(i=1;ilen;i+) for(intj=0;jarrayj+1) floatnum; num=arrayj; arrayj=arrayj+1; arrayj+1

27、=num; intpos=1; for(i=0;ichinaNum; elseif(type=2) num=head-mathNum; elseif(type=3) num=head-englishNum; elseif(type=4) num=int(head-result); elseif(type=5) num=int(head-average); elseif(type=6) num=int(head-num); intn=0; if(int(arrayi)=int(num) if(int(arrayi)!=int(arrayi+1) if(n=0) n=pos; head-pos=p

28、os; pos+; else head-pos=n; head=head-next; head=pH; deletearray; voidCount(student*&head) head-result=head-chinaNum+head-englishNum+head-mathNum; head-average=head-result/3; voidDeleteAll(student*&head) student*cp,*np; cp=head; while(cp) np=cp-next; deletecp; cp=np; head=NULL; voidChaXun(stringstr,s

29、tudent*head) Sort(head,4,1); cout欢迎使用查询功能endlendl; cout一般查询2-查找最多3-查找最少s; while(s0!=1&s0!=2&s0!=3) cout你输入错误,请重新输入.s; if(s0=1) cout按什么查询?endl; cout姓名2-座号3-语文成绩4-数学成绩 英语成绩6-总分7-平均分8-排名str; while(str0!=1&str0!=2& str0!=3&str0!=4& str0!=5&str0!=6& str0!=7&str0!=8) cout你输入错误,请重新输入.str; charfindStr30; co

30、ut请输入要查找的关键字或关键数:findStr; switch(str0) case1: Find(head,findStr,1); break; case2: Find(head,findStr,2); break; case3: Find(head,findStr,3); break; case4: Find(head,findStr,4); break; case5: Find(head,findStr,5); break; case6: Find(head,findStr,6); break; case7: Find(head,findStr,7); break; case8: Fi

31、nd(head,findStr,8); break; elseif(s0=2) cout请输入要按什么查询?endl; cout语文成绩2-数学成绩 英语成绩4-总分5-平均分6-排名s; switch(s0) case1: FindMaxOrMin(head,1,1); break; case2: FindMaxOrMin(head,2,1); break; case3: FindMaxOrMin(head,3,1); break; case6: FindMaxOrMin(head,6,1); break; case5: FindMaxOrMin(head,5,1); break; defa

32、ult: FindMaxOrMin(head,4,1); break; elseif(s0=3) cout请输入要按什么查询?endl; cout语文成绩2-数学成绩 英语成绩4-总分5-平均分6-排名s; switch(s0) case1: FindMaxOrMin(head,1,2); break; case2: FindMaxOrMin(head,2,2); break; case3: FindMaxOrMin(head,3,2); break; case6: FindMaxOrMin(head,6,2); break; case5: FindMaxOrMin(head,5,2); br

33、eak; default: FindMaxOrMin(head,4,2); break; voidZengJia(stringstr,student*&head) student*pNew=newstudent; cout欢迎使用增加功能endlendl; cout请输入新学生的名字:pNew-name; cout请输入新学生的座号:pNew-num; cout请输入他的语文分数:pNew-chinaNum; cout请输入他的数学分数pNew-mathNum; cout请输入他的英语分数pNew-englishNum; cout最前面2-最后面)str; while(str0!=1&str0!=2)

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

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁