C++学生管理系统代码

上传人:沈*** 文档编号:194002813 上传时间:2023-03-13 格式:DOCX 页数:33 大小:43.51KB
收藏 版权申诉 举报 下载
C++学生管理系统代码_第1页
第1页 / 共33页
C++学生管理系统代码_第2页
第2页 / 共33页
C++学生管理系统代码_第3页
第3页 / 共33页
资源描述:

《C++学生管理系统代码》由会员分享,可在线阅读,更多相关《C++学生管理系统代码(33页珍藏版)》请在装配图网上搜索。

1、C+学生管理系统代码#include #include #include #include #include #include using namespace std; const int NAME_NUM=30; struct student char nameNAME_NUM; float num; float chinaNum; float englishNum; float mathNum; float average; float result; int pos; student *next; ; void Print(student *head); void InsertFront

2、(student* &head, student *pNew); void InsertRear(student* &head, student *pNew); student* Find(student *head, char *findStr, char type); student* Read; void Write(student* head); void ShowList(student* head); int GetLength(student* head); void Delete(student* &head, char *delStr,int delNum); void Fi

3、ndMaxOrMin(student *head,char type,char maxOrMin); void Reword(student *pStd); void Sort(student *&head, char type,char maxOrMin); void Count(student *&head); void DeleteAll(student *&head); bool Enter(char type); void SetTitle(bool isLoad); void AboutMe; void ChaXun(string str,student *head); void

4、PaiMing(string str, student* head); void ShanChu(string str, student *&head); void XianShi(string str, student *head); void XuiGai(string str, student *&head); void ZengJia(string str, student* &head); int Run; bool Enter(char type) ofstream out(Password.pwd,ios:app); ifstream in(Password.pwd); stri

5、ng s2; int num=0; string zhangHao; string miMa; while(!in.eof) insnum; num+; if(num=2) break; if(pare()=0 | type=2 ) if(pare()=0 & type!=2) cout你是第一次使用本程序,请设置帐号和密码.endl; else bool isLoad=false; isLoad=Enter(1); if(isLoad=true) cout修改用户.endl; out.close; out.open(Password.pwd,ios:trunc); else cout你输入的

6、密码错误.endl; cout你不是管理员不能修改密码.endl; return false; couts0; couts1; string s1,s2; for(int i=0; is0.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; string s1,s2; for(int i=0; is0.size; i+) s1+=char(int(s0i)-11); for( i=0;

7、 is1.size; i+) s2+=char(int(s1i)-11); coutzhangHao; coutmiMa; if(zhangHpare(s1)=0 & miMpare(s2)=0) return true; else return false; return false; void Print(student *head) student *pHead=head; int num=strlen(head-name); while(head) if(numname) num=strlen(head-name); head=head-next; head=pHead; coutse

8、tw(num)namesetw(8) numsetw(10)chinaNum setw(10)mathNumsetw(10) englishNumsetw(8)result setw(8)averagesetw(5)posendl; void ShowList(student* head) cout姓名:setw(8)座号:setw(10) 语文分数:setw(10) 数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(6)名次:endlnext; coutnext; out.close; student* Read ifstream in(Stude

9、nt.dat); student *head; student *pP; student *pEnd; pP=new student; pEnd=head=pP; student *pS=new student; memset(pS-name,0,NAME_NUM); in.read(char*)pS,sizeof(student); if(strcmp(pS-name,0)=0) return NULL; strcpy(pP-name,pS-name); pP-num=pS-num; pP-chinaNum=pS-chinaNum; pP-englishNum=pS-englishNum;

10、pP-mathNum=pS-mathNum; while(!in.eof) in.read(char*)pS,sizeof(student); pEnd-next=pP; pEnd=pP; pP=new student; strcpy(pP-name,pS-name); pP-num=pS-num; pP-chinaNum=pS-chinaNum; pP-englishNum=pS-englishNum; pP-mathNum=pS-mathNum; pEnd-next=NULL; delete pP; return head; student* Find(student *head,char

11、 *findStr, char type) /*参数说明: type=1 按 名字 查找 type=2 按 座号 查找 type=3 按 语文 查找 type=4 按 数学 查找 type=5 按 英语 查找 type=6 按 总分 查找 type=7 按 平均分 查找 type=8 按 排名 查找 /没有实现 */ bool isFind=false; student *firstStd=NULL; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10) 数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(5)名次:endln

12、ame,findStr)=0) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=2) if(int(head-num)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=3) if(int(head-chinaNum)=int(a

13、tof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=4) if(int(head-mathNum)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=5) if(int(head-englishNum)=in

14、t(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=6) if(int(head-result)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=7) if(int(head-average)=int

15、(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; else if(type=8) if(int(head-pos)=int(atof(findStr) if(firstStd=NULL) firstStd=head; Print(head); isFind=true; if(head-next=NULL) return firstStd; head=head-next; if(isFind=false) cout找不到你要找的

16、记录.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; pS-next=NULL; pEnd-next=pS; head=pHead; void InsertFront(student* &head, student *pNew) student *pHead=new student; strcpy(pHead-name,pN

17、ew-name); pHead-num=pNew-num; pHead-chinaNum=pNew-chinaNum; pHead-englishNum=pNew-englishNum; pHead-mathNum=pNew-mathNum; pHead-next=head; head=pHead; int GetLength(student *head) int len=0; while(head) len+; head=head-next; return len; void Delete(student* &head, char *delStr,int delNum) student* p

18、Del,*pNew,*pHead; bool isFind=false; pHead=head; if(strcmp(head-name,delStr)=0) pNew=head-next; delete head; head=pNew; if(delNum=2) coutendl因为要删除的记录在前面,所有只删除第一记录.next) if(delNum=2) if(strcmp(head-next-name,delStr)=0) pNew=head-next-next; pDel=head-next; delete pDel; head-next=pNew; head=pHead; isFi

19、nd=true; else if(strcmp(head-next-name,delStr)=0) pNew=head-next-next; pDel=head-next; delete pDel; head-next=pNew; head=pHead; return ; head=head-next; head=pHead; if(isFind=false) cout找不到你要删除的记录.endl; else cout删除记录成功.chinaNum); else if (type=2) maxNum=int(head-mathNum); else if (type=3) maxNum=int

20、(head-englishNum); else if (type=4) maxNum=int(head-result); else if (type=5) maxNum=int(head-average); else if (type=6) maxNum=head-pos; else cout你输入错误,请重新输入.endl; return ; while(head) if(maxOrMin=1) if(type=1) if(maxNumchinaNum) maxNum=int(head-chinaNum); else if (type=2) if(maxNummathNum) maxNum=

21、int(head-mathNum); else if (type=3) if(maxNumenglishNum) maxNum=int(head-englishNum); else if (type=4) if(maxNumresult) maxNum=int(head-result); else if (type=5) if(maxNumaverage) maxNum=int(head-average); else if (type=6) if(maxNumpos) maxNum=head-pos; else if(type=1) if(maxNumint(head-chinaNum) ma

22、xNum=int(head-chinaNum); else if (type=2) if(maxNumint(head-mathNum) maxNum=int(head-mathNum); else if (type=3) if(maxNumint(head-englishNum) maxNum=int(head-englishNum); else if (type=4) if(maxNumint(head-result) maxNum=int(head-result); else if (type=5) if(maxNumint(head-average) maxNum=int(head-a

23、verage); else if (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); else if (type=2) if(int(head-mathNum)=maxNum) Print(head); else if (type=3) if(int(

24、head-englishNum)=maxNum) Print(head); else if (type=4) if(int(head-result)=maxNum) Print(head); else if (type=5) if(int(head-average)=maxNum) Print(head); else if (type=6) if(head-pos=maxNum) Print(head); head=head-next; void Reword(student *pStd) if(pStd!=NULL) cout请输入学生的新名字:pStd-name; cout请输入学生的座号

25、pStd-num; cout请输入学生的语文分数pStd-chinaNum; cout请输入学生的数学分数pStd-mathNum; cout请输入学生的英语分数pStd-englishNum; else return ; void Sort(student *&head, char type,char maxOrMin) /*参数说明: type=1 按 语文 排列 type=2 按 数学 排列 type=3 按 英语 排列 type=4 按 总分 排列 type=5 按 平均分 排列 type=6 按 座号 排列 */ student *pHead,*pH; pHead=pH=head;

26、int len=GetLength(head); float *array=new floatlen; int i; int x=0; float num=0; while(head) Count(head); if(type=1) num=head-chinaNum; else if(type=2) num=head-mathNum; else if(type=3) num=head-englishNum; else if(type=4) num=head-result; else if(type=5) num=head-average; else if(type=6) num=head-n

27、um; arrayx=num; x+; head=head-next; head=pHead; if(maxOrMin=1) for( i=1; ilen; i+) for(int j=0; jlen-i; j+) if(arrayjarrayj+1) float num; num=arrayj; arrayj=arrayj+1; arrayj+1=num; else for( i=1; ilen; i+) for(int j=0; jarrayj+1) float num; num=arrayj; arrayj=arrayj+1; arrayj+1=num; int pos=1; for(i

28、=0; ichinaNum; else if(type=2) num=head-mathNum; else if(type=3) num=head-englishNum; else if(type=4) num=int(head-result); else if(type=5) num=int(head-average); else if(type=6) num=int(head-num); int n=0; if(int(arrayi)=int(num) if(int(arrayi)!=int(arrayi+1) if(n=0) n=pos; head-pos=pos; pos+; else

29、 head-pos=n; head=head-next; head=pH; delete array; void Count(student *&head) head-result=head-chinaNum+head-englishNum+head-mathNum; head-average=head-result/3; void DeleteAll(student* &head) student *cp,*np; cp=head; while(cp) np=cp-next; delete cp; cp=np; head=NULL; void ChaXun(string str,studen

30、t *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; c

31、har findStr30; cout请输入要查找的关键字或关键数:findStr; switch(str0) case 1: Find(head,findStr,1); break; case 2: Find(head,findStr,2); break; case 3: Find(head,findStr,3); break; case 4: Find(head,findStr,4); break; case 5: Find(head,findStr,5); break; case 6: Find(head,findStr,6); break; case 7: Find(head,find

32、Str,7); break; case 8: Find(head,findStr,8); break; else if(s0=2) cout请输入要按什么查询?endl; cout语文成绩 2-数学成绩 英语成绩 4-总分 5-平均分 6-排名s; switch(s0) case 1: FindMaxOrMin(head,1,1); break; case 2: FindMaxOrMin(head,2,1); break; case 3: FindMaxOrMin(head,3,1); break; case 6: FindMaxOrMin(head,6,1); break; case 5:

33、FindMaxOrMin(head,5,1); break; default: FindMaxOrMin(head,4,1); break; else if(s0=3) cout请输入要按什么查询?endl; cout语文成绩 2-数学成绩 英语成绩 4-总分 5-平均分 6-排名s; switch(s0) case 1: FindMaxOrMin(head,1,2); break; case 2: FindMaxOrMin(head,2,2); break; case 3: FindMaxOrMin(head,3,2); break; case 6: FindMaxOrMin(head,6,

34、2); break; case 5: FindMaxOrMin(head,5,2); break; default: FindMaxOrMin(head,4,2); break; void ZengJia(string str, student* &head) student *pNew=new student; cout欢迎使用增加功能endlendl; cout请输入新学生的名字 :pNew-name; cout请输入新学生的座号 :pNew-num; cout请输入他的语文分数 :pNew-chinaNum; cout请输入他的数学分数pNew-mathNum; cout请输入他的英语分

35、数pNew-englishNum; cout最前面 2-最后面)str; while(str0!=1 & str0!=2) cout你输入错误,请重新输入.endl; cout最前面 2-最后面)str; if(str0=1) InsertFront(head,pNew); else if(str0=2) InsertRear(head,pNew); cout新学生增加成功.endl; void ShanChu(string str, student *&head) char delStr30; cout欢迎使用删除功能endlendl; cout查询删除 2-全部删除str; while(s

36、tr0!=1 & str0!=2) cout输入错误,请重新输入.str; if(str0=1) cout请输入要删除的关键字delStr; cout删除第一条找到的记录 2-删除所有找到的记录str; while(str0!=1&str0!=2) cout你输入错误,请重新输入.str; cout删除 2-取消s; if(str0=1) if(str0=1) Delete(head,delStr,1); else Delete(head,delStr,2); else cout你已经取消删除了.endl; else cout你真的要删除全部数据吗?这样会使你的数据全部丢失哦.endl; co

37、ut全部删除 2-取消删除str; if(str0=1) DeleteAll(head); else cout你已经取消删除了.endl; void PaiMing(string str, student* head) string s; cout欢迎使用排名功能endlendl; cout升序 2-降序s; cout请输入要按什么排名?endl; cout语文成绩 2-数学成绩 3-英语成绩 总分 5-平均分 6-座号str; while(str0!=1 & str0!=2 & str0!=3 & str0!=4 & str0!=5 & str0!=6 ) cout你输入错误,请重新输入.s

38、tr; cout姓名:setw(8)座号:setw(10) 语文分数:setw(10) 数学分数: setw(10)英语分数:setw(8)总分数: setw(8)平均分:setw(6)名次:endlendl; if(s0=2) switch(str0) case 1: Sort(head,1,1); break; case 2: Sort(head,2,1); break; case 3: Sort(head,3,1); break; case 4: Sort(head,4,1); break; case 5: Sort(head,5,1); break; case 6: Sort(head

39、,6,1); break; else switch(str0) case 1: Sort(head,1,2); break; case 2: Sort(head,2,2); break; case 3: Sort(head,3,2); break; case 4: Sort(head,4,2); break; case 5: Sort(head,5,2); break; case 6: Sort(head,6,2); break; ShowList(head); return ; void XianShi(string str, student *head) Sort(head,4,1); s

40、tring s; cout欢迎使用显示功能endl; cout显示全部记录 2-显示记录数目s; if(s0=2) cout记录的数目是:GetLength(head)endl; else ShowList(head); void XuiGai(string str, student *&head) string s; student *std; cout欢迎使用修改功能endl; cout请输入你要按什么查询endl; cout姓名 2-座号 3-语文成绩 4-数学成绩 英语成绩 str; while(str0!=1 & str0!=2 & str0!=3 & str0!=4 & str0!

41、=5 ) cout你输入错误,请重新输入.str; char findStr30; cout请输入要查找的关键字或关键数:findStr; switch(str0) case 1: std=Find(head,findStr,1); Reword(std); break; case 2: std=Find(head,findStr,2); Reword(std); break; case 3: std=Find(head,findStr,3); Reword(std); break; case 4: std=Find(head,findStr,4); Reword(std); break; c

42、ase 5: std=Find(head,findStr,5); Reword(std); break; Write(head); if(std!=NULL) cout修改成功.endl; int Run bool isLoad=false; student* head=NULL; student *pNew=new student; head=Read; SetTitle(false); if(head!=NULL) Sort(head,5,1); Count(head); string str; SetTitle(false); cout 欢迎使用学生管理系统 endlendl; cout用户登陆 2-退出程序 str; if(str0=2) AboutMe; return 0; else isLoad=Enter(1); system(cls); if(isLoad=true) SetTitle(true); cout 恭喜,您输入的密码正确.可以对本系统的进行任何操作.endl; else cout Sorry,您输入的密码错误.你不能修改本系统的任何内容.endl; begin: coutendlendl; cout 欢迎使用学生管理系统 endlendl; cout增加功能 2-查询功能endl; cout删除功能

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


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