C++选课管理系统课程设计.pdf

上传人:tbuqq 文档编号:5416042 上传时间:2020-05-04 格式:PDF 页数:19 大小:102.16KB
返回 下载 相关 举报
C++选课管理系统课程设计.pdf_第1页
第1页 / 共19页
C++选课管理系统课程设计.pdf_第2页
第2页 / 共19页
C++选课管理系统课程设计.pdf_第3页
第3页 / 共19页
C++选课管理系统课程设计.pdf_第4页
第4页 / 共19页
C++选课管理系统课程设计.pdf_第5页
第5页 / 共19页
点击查看更多>>
资源描述

《C++选课管理系统课程设计.pdf》由会员分享,可在线阅读,更多相关《C++选课管理系统课程设计.pdf(19页珍藏版)》请在三一文库上搜索。

1、/ /头文件及函数声明 #include #include #include #include #include #include using namespace std; class XS; class JS; class stu; class subject ; int menu();/ 主菜单 int menu1();/ 学生选课端菜单 int menu2();/ 管理端菜单 template void ADD(T P);/ 增加功能函数模板 template void LOOK(T P) ;/ 查看功能函数模板 template void DELETE(T P);/ 删除功能函数模板

2、void xuanke(XS P,char nu,char na);/ 选课功能函数 void tuixuan(XS P,char nu,char na);/退选课程功能函数 void lookyixuan(XS P,char nu,char na);/查看学生已选课程函数 void dayin(XS P,char nu,char na);/ 打印学生选课情况函数 void tuichu(); / 退出系统函数 void password();/ 密码检查功能函数 / /定义课程信息类 struct course char cnum10; char cname20; char cteacher

3、20; float credit; ; struct Course course kecheng; Course *next; ; class subject Course *head; /头指针 Course *p; /当前指针 public: subject()head=p=NULL; ; void Add(); void Delete(); /删除课程 int Search(char nu); /根据课程号查找课程 void ReadFile(); /从文件中读取课程信息 void WriteFile(); /向文件写入课程信息 void Display(); /在屏幕中输出全部课程信息

4、 friend XS; friend JS; friend void xuanke(XS P,char nu,char na); ; void subject:Add() p=new Course; coutp-um; if(Search(p-um)=0) coutp-ame; coutp-kecheng.cteacher; coutp-kecheng.credit; p-next=head; /头插入建链表 head=p; coutnext ; char kh10; coutkh; while(kc!=NULL) n+; if(strcmp(kc-um,kh)=0) break; kc=kc

5、-next; if(kc=NULL)coutnext; else for(int i=1;inext; if(q2=NULL) q1=NULL; else q1-next=q2-next; um,nu)=0) break; kc=kc-next; if(kc=NULL)return 0; else return 1; void subject:Display() /在屏幕中输出全部课程信息 if(head=NULL) ame kecheng.cteacherkecheng.creditnext; coutkecheng,sizeof(p-kecheng) p-next=head; head=p

6、; p=new Course; fip.close(); delete p; void subject:WriteFile() /向文件写入课程信息 Course *s=head; ofstream fop; fop.open(“课程信息 .dat“,ios:binary|ios:trunc); if(!fop) coutkecheng ,sizeof(s-kecheng) s=s-next; fop.close(); / 定义教师信息类 struct teacher char tnum10; char tname20; char zhicheng20; ; struct Teacher te

7、acher jiaoshi; Teacher *next; ; class JS Teacher *head; /头指针 Teacher *p; /当前指针 public: JS()head=p=NULL; void Add(); void Delete(); void Search(char na); /通过教师姓名查找任课教师 int Search1(char nu); /通过教师号查找教师 void ReadFile(); /从文件中读取教师信息 void WriteFile(); /向文件写入教师信息 void Display(); /在屏幕中输出全部教师信息 friend XS; ;

8、 void JS:Add() p=new Teacher; coutp-jiaoshi.tnum; if(Search1(p-jiaoshi.tnum)=0) coutp-jiaoshi.tname; coutp-jiaoshi.zhicheng; p-next=head; /头插入建链表 head=p; coutnext ; char zh10; coutzh; while(js!=NULL) n+; if(strcmp(js-jiaoshi.tnum ,zh)=0) break; js=js-next; if(js=NULL)coutnext; else for(int i=1;inext

9、; if(q2=NULL) q1=NULL; else q1-next=q2-next; coutjiaoshi.tname)=0) break; js=js-next; if(js!=NULL) coutjiaoshi.tnum jiaoshi.tname jiaoshi.zhicheng jiaoshi.tnum jiaoshi.tname jiaoshi.zhicheng next; coutjiaoshi.tnum)=0) break; js=js-next; if(js=NULL)return 0; else return 1; void JS:WriteFile() Teacher

10、 *s=head; ofstream fop; char xs=“ 教师信息 .dat“; fop.open( xs,ios:binary|ios:trunc); if(!fop) coutjiaoshi ,sizeof(s-jiaoshi ) s=s-next; fop.close(); void JS:ReadFile() p=new Teacher ; ifstream fip(“ 教师信息 .dat“,ios:in|ios:binary); /以二进制形式打开文件 if(!fip)coutjiaoshi ,sizeof(p-jiaoshi) p-next=head; head=p; p

11、=new Teacher; fip.close(); delete p; / 定义学生信息类 struct student char snum10; char sname20; ; struct Student student xuesheng; Student *next; class stu Student *head; /头指针 Student *p; /当前指针 public: stu()head=p=NULL; void Add(); /增加学生 void Delete(); /删除学生 int Search(char nu,char na); / 按学生学号和姓名查找 int Se

12、arch(char nu); /按学生学号查找 void ReadFile(); /将所有学生的信息写入文件保存 void WriteFile(); /从文件读出学生信息 void Display(); /显示所有学生 friend XS; ; void stu:Add() p=new Student; coutp-xuesheng.snum ; if(Search(p-xuesheng.snum)=0) coutp-xuesheng.sname; p-next=head; /头插入建链表 head=p; coutnext ; char kh10; coutkh; while(kc!=NULL

13、) n+; if(strcmp(kc-xuesheng.snum ,kh)=0) break; kc=kc-next; if(kc=NULL)coutnext; else for(int i=1;inext; if(q2=NULL) q1=NULL; else q1-next=q2-next; coutxuesheng.snum,nu)=0 kc=kc-next; if(kc=NULL)return 0; else return 1; int stu:Search(char nu) Student *kc=head; while(kc!=NULL) if(strcmp(kc-xuesheng.

14、snum,nu)=0) break; kc=kc-next; if(kc=NULL)return 0; else return 1; void stu:WriteFile() Student *s=head; ofstream fop; char xs=“ 学生信息 .dat“; fop.open( xs,ios:binary|ios:trunc); if(!fop) coutxuesheng,sizeof(s-xuesheng ) s=s-next; void stu:ReadFile() p=new Student; ifstream fip(“ 学生信息 .dat“,ios:in|ios

15、:binary); if(!fip)coutxuesheng,sizeof(p-xuesheng ) p-next=head; head=p; p=new Student ; fip.close(); delete p; void stu:Display() if(head=NULL) coutxuesheng.snumxuesheng.snamenext; um,nu)=0) break; sub.p=sub.p-next; strcpy(p-um ,sub.p -um); strcpy(p-ame ,sub.p -ame ); strcpy(p-kecheng.cteacher,sub.p

16、 -kecheng.cteacher ); p-kecheng.credit =sub.p-kecheng.credit ; p-next =head; head=p; um ,nu)=0) break; kc=kc-next; if(kc=NULL)return 0; else return 1; void XS:Deletecourse(char nu) if(head!=NULL) int n=0; Course *kc=head,*q1=head,*q2=head-next ; while(kc!=NULL) n+; if(strcmp(kc-um,nu)=0) break; kc=k

17、c-next; if(kc=NULL)coutnext; else for(int i=1;inext; if(q2=NULL) q1=NULL; else q1-next=q2-next; ame kecheng.cteacherk echeng.creditnext; coutkecheng.credit; p=p-next; return tcredit; void XS:ReadFilecourse() p=new Course; char S10; ifstream fip; strcpy(S,num ); strcat(S,“.txt“); fip.open(S); if(!fip

18、) coutkecheng,sizeof(p-kecheng) p-next=head; head=p; p=new Course; fip.close(); void XS:WriteFilecourse() Course *s=head; ofstream file; char S10; strcpy(S,num); strcat(S,“.txt“); file.open(S); if(!file) coutkecheng ,sizeof(s-kecheng ) s=s-next; file.close(); / 各功能函数 template /增加功能函数模板 void ADD(T P)

19、 system(“cls“); P.ReadFile(); int N,i; coutN; for(i=0;i/查看功能函数模板 void LOOK(T P) system(“cls“); P.ReadFile(); P.Display(); getchar(); cout/删除功能函数模板 void DELETE(T P) system(“cls“); P.ReadFile(); P.Display(); P.Delete(); P.WriteFile(); getchar(); coutkh; coutY_N; if(Y_N=Y|Y_N=y) char t20; Course *kc=su

20、b.head; while(kc!=NULL) if(strcmp(kc-um,kh)=0) break; kc=kc-next; if(kc!=NULL) strcpy(t,kc-kecheng.cteacher); J.Search(t); else coutY_N; if(Y_N=Y|Y_N=y)goto Loop1; else if(Y_N=N|Y_N=n)P.WriteFilecourse(); else coutkh; P.Deletecourse(kh); P.WriteFilecourse(); getchar(); coutY_N; if(Y_N=Y|Y_N=y)goto L

21、oop3; else if(Y_N!=N if(b=0 if(b=0 if(b=0 coutna; if(p1.Search(nu,na)=0) cout“nntt对不起,学号或姓名输入错误!按任意键返回“; getchar();getchar();goto P0; else P1:b1=menu1(); switch(b1) case 0:goto P0;break; case 1:xuanke(p,nu,na);goto P1;break; case 2:tuixuan(p,nu,na);goto P1;break; case 3:lookyixuan(p,nu,na);goto P1;b

22、reak; case 4:dayin(p,nu,na);goto P1;break; if(b0=2) password(); P2:switch(b2=menu2() case 0:goto P0;break; case 1:ADD(p1);goto P2;break; case 2:LOOK(p1);goto P2;break; case 3:DELETE(p1);goto P2;break; case 4:ADD(p2);goto P2;break; case 5:LOOK(p2);goto P2;break; case 6:DELETE(p2);goto P2;break; case 7:ADD(p3);goto P2;break; case 8:LOOK(p3);goto P2;break; case 9:DELETE(p3);goto P2;break; if(b0=0) tuichu();

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 其他


经营许可证编号:宁ICP备18001539号-1