学生选课系统代码[互联网+].doc

上传人:rrsccc 文档编号:9349550 上传时间:2021-02-20 格式:DOC 页数:15 大小:62.50KB
返回 下载 相关 举报
学生选课系统代码[互联网+].doc_第1页
第1页 / 共15页
学生选课系统代码[互联网+].doc_第2页
第2页 / 共15页
学生选课系统代码[互联网+].doc_第3页
第3页 / 共15页
学生选课系统代码[互联网+].doc_第4页
第4页 / 共15页
亲,该文档总共15页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《学生选课系统代码[互联网+].doc》由会员分享,可在线阅读,更多相关《学生选课系统代码[互联网+].doc(15页珍藏版)》请在三一文库上搜索。

1、#include #includeint N1,N2,kk1,kk2,kk3;struct couse * head1;struct student * head2;struct couseint num1;char name120;int score;int nelepeo;int Melepeo;struct couse * next;struct studentint num2;char name220;int nelenum50;int nelen;struct student * next;void Ms()for(kk1=0;kk11100;kk1+)for(kk2=0;kk212

2、00;kk2+)for(kk3=0;kk3num1,p1-name1,&p1-score,&p1-Melepeo);p1-nelepeo=0;head1=NULL;while(p1-num1!=0)N1=N1+1;if(N1=1)head1=p1;else p2-next=p1;p2=p1;p1=(struct couse * )malloc(sizeof(struct couse);scanf(%d%s%d%d,&p1-num1,p1-name1,&p1-score,&p1-Melepeo);p1-nelepeo=0;p2-next=NULL;void filec()FILE * fp;ch

3、ar filepath20; struct couse *p1,*p2;N1=0;printf(输入要读入的文件路径:);getchar();gets(filepath); if(fp=fopen(filepath,r)=NULL) printf(找不到%s文件!n,filepath); exit(0); p1=p2=(struct couse*)malloc(sizeof(struct couse);fscanf(fp,%d%s%d%d%d,&p1-num1,p1-name1,&p1-score,&p1-nelepeo,&p1-Melepeo);head1=NULL;while(!feof(

4、fp) N1=N1+1;if(N1=1)head1=p1;else p2-next=p1;p2=p1;p1=(struct couse * )malloc(sizeof(struct couse);fscanf(fp,%d%s%d%d%d,&p1-num1,p1-name1,&p1-score,&p1-nelepeo,&p1-Melepeo); p2-next=NULL;void inputc() int i;printf(ttt录入课程信息n); printf(n1.从键盘录入n);printf(2.从文件录入n);printf(3.返回主菜单n);printf(请选择(13):n); sc

5、anf(%d,&i);switch(i)case(1):keyboardc();break;case(2):filec();break;case(3):break;void insertc(struct couse *incouse)struct couse *p0,*p1,*p2;p1=head1;p0=incouse;if(head1=NULL)head1=p0; p0-next=NULL;elsewhile(p0-num1 p1-num1) & (p1-next!=NULL) p2=p1; p1=p1-next; if(p0-num1 num1) if(head1=p1) head1=p

6、0; else p2-next=p0; p0-next=p1; else p1-next=p0;p0-next=NULL;N1=N1+1;void delc(int num1)struct couse *p1,*p2;if(head1=NULL)printf(n没有课程,无法删除!n);goto end; p1=head1; while(num1!=p1-num1 & p1-next!=NULL) p2=p1; p1=p1-next;if(num1=p1-num1)if(p1=head1) head1=p1-next;else p2-next=p1-next;printf(已删除该编号课程!n

7、);N1=N1-1;else printf(无该编号的课程!n);end:;void managementc()struct couse * incouse;int i,num1;printf(ttt课程管理n);printf(1.新增课程n);printf(2.删除课程n);printf(3.返回主菜单n);printf(请选择(13):n);scanf(%d,&i);switch(i)case(1):incouse=(struct couse *)malloc(sizeof(struct couse);printf(课程编号t课程名称t学分t课程人数上限n); scanf(%d%s%d%d

8、,&incouse-num1,incouse-name1,&incouse-score,&incouse-Melepeo);incouse-nelepeo=0;insertc(incouse);break;case(2):printf(请输入要删除课程的编号:n);scanf(%d,&num1);delc(num1);break;case(3):break;void keyboards()int i;struct student *p1,*p2;N2=0;p1=p2=(struct student *)malloc(sizeof(struct student);printf(学生学号t学生姓名

9、n);scanf(%d%s,&p1-num2,p1-name2);p1-nelen=0;for(i=0;inelenumi=0;head2=NULL;while(p1-num2!=0)N2=N2+1;if(N2=1)head2=p1;else p2-next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);scanf(%d%s,&p1-num2,p1-name2);p1-nelen=0;for(i=0;inelenumi=0;p2-next=NULL;void files()int i=0;FILE * fp;char

10、filepath20; struct student *p1,*p2;N2=0;printf(输入要读入的文件路径:);getchar();gets(filepath); if(fp=fopen(filepath,r)=NULL) printf(找不到%s文件!n,filepath); exit(0); p1=p2=(struct student*)malloc(sizeof(struct student);fread(p1,sizeof(struct student),1,fp);head2=NULL;while(!feof(fp)i=0;N2=N2+1;if(N2=1)head2=p1;e

11、lse p2-next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);fread(p1,sizeof(struct student),1,fp); p2-next=NULL;void inputs()int i;printf(ttt录入学生信息n);printf(n1.从键盘录入n);printf(2.从文件录入n);printf(3.返回主菜单n);printf(请选择(13):n);scanf(%d,&i);switch(i)case(1):keyboards();break;case(2):files();bre

12、ak;case(3):break;void inserts(struct student * incouse)struct student *p0,*p1,*p2;p1=head2;p0=incouse;if(head2=NULL)head2=p0;p0-next=NULL;elsewhile(p0-num2 p1-num2) & (p1-next!=NULL)p2=p1;p1=p1-next;if(p0-num2 num2)if(head2=p1) head2=p0;else p2-next=p0;p0-next=p1;elsep1-next=p0;p0-next=NULL;N2=N2+1;

13、void dels(int num2)struct student *p1,*p2;if(head2=NULL)printf(n没有该学生信息,无法删除!n);goto end;p1=head2;while(num2!=p1-num2 & p1-next!=NULL)p2=p1;p1=p1-next;if(num2=p1-num2)if(p1=head2) head2=p1-next;else p2-next=p1-next;printf(已删除该学生信息!n);N2=N2-1;else printf(无该学号的学生!n);end:;void managements()struct stude

14、nt * incouse;int i,num2;printf(ttt学生信息管理n);printf(1.新增学生信息n);printf(2.删除学生信息n);printf(3.返回主菜单n);printf(请选择(13):n);scanf(%d,&i);switch(i)case(1):incouse=(struct student *)malloc(sizeof(struct student);incouse-nelen=0;incouse-nelenum0=0;printf(学生学号t学生姓名n);scanf(%d%s,&incouse-num2,incouse-name2);insert

15、s(incouse);break;case(2):printf(请输入要删除学生的学号:n);scanf(%d,&num2);dels(num2);break;case(3):break;void elect(struct student * s)struct couse * p;int num1,i;printf(请输入要选课的编号:n);scanf(%d,&num1);for(i=0;s-nelenumi!=0;i+);s-nelenumi=num1;(s-nelen)+;p=head1;while(p-num1!=num1) p=p-next; (p-nelepeo)+;void che

16、ak()char e;struct couse * c;struct student * s;int num2,i,j=0,t=0;printf(请输入你的学号:);scanf(%d,&num2);s=head2;while(s-num2!=num2 & s-next!=NULL) s=s-next;if(s-num2!=num2)printf(不存在你的信息,请进入主菜单录入你的信息!n);goto end;c=head1;printf(你的可选课程编号:n);while(c!=NULL)for(t=0,i=0;s-nelenumi!=0;i+)if(c-num1=s-nelenumi) t

17、=1;if(t=0 & (c-nelepeo!=c-Melepeo)printf(%dn,c-num1);j+;c=c-next;if(j=0) printf(你已选完所有课程,无法再多选!n);goto end;printf(选课(y/n)?:n);getchar();e=getchar();i=0;while(e=y)elect(s);printf(继续选课(y/n)?:n);getchar();e=getchar();end:;void back(struct student * p)struct couse * p1;int num1,i,j;printf(请输入你要退掉的课程编号:n

18、);scanf(%d,&num1);p1=head1;while(p1-num1!=num1) p1=p1-next;for(i=0;p-nelenumi!=num1;i+);for(j=i;p-nelenumj!=0;j+) p-nelenumj=p-nelenumj+1;p-nelenum-j=0; (p1-nelepeo)-;printf(退课成功!n);void hcheak()char c;struct couse * p0;struct student * p;int num2,i,f=0;printf(请输入学号:n);scanf(%d,&num2);p=head2;while(

19、p-num2!=num2 & p!=NULL) p=p-next;if(p=NULL)printf(不存在你的信息,请回主菜单录入信息:n);goto end;printf(已选课程编号:n);if(p-nelenum0=0)printf(你还没选课!n);goto end;for(i=0;p-nelenumi!=0;i+) printf(%dn,p-nelenumi);p0=head1;while(p0-num1!=p-nelenumi) p0=p0-next;f=f+p0-score;printf(总学分:%dn,f);printf(是否进行退课(y/n)?);getchar();c=ge

20、tchar();while(c=y)back(p);printf(继续退课(y/n)?);getchar();(p-nelen)-;end:;void elective()int i;printf(ttt学生选课n);printf(1.查询可选课程n);printf(2.查询已选课程n);printf(3.返回主菜单n);printf(请输入(13):n);scanf(%d,&i);switch(i)case(1):cheak();break;case(2):hcheak();break;case(3):break;void listc()struct couse * p;p=head1;pr

21、intf(课程编号 课程名称 学分 课程已选人数 课程人数上限n);while(p!=NULL)printf(%-8d%10s%6d%8d%12dn,p-num1,p-name1,p-score,p-nelepeo,p-Melepeo);p=p-next;void lists()struct student * p;p=head2;printf(学生学号 学生姓名 已选课程数量n);while(p!=NULL)printf(%-4d %10s %6dn,p-num2,p-name2,p-nelen);p=p-next;void intoc()FILE * fp;struct couse * p

22、;char filepath30; printf(输入课程信息要保存的文件路径:);getchar(); gets(filepath); if(fp=fopen(filepath,w)=NULL) printf(n保存失败!); exit(0); p=head1;while(p!=NULL)fprintf(fp,%d %s %d %d %dn,p-num1,p-name1,p-score,p-nelepeo,p-Melepeo);p=p-next;fclose(fp); printf(课程信息已保存在%s中!n,filepath); void intos()FILE * fp;struct s

23、tudent * p;char filepath30; printf(输入学生信息要保存的文件路径:);getchar(); gets(filepath); if(fp=fopen(filepath,w)=NULL) printf(n保存失败!); exit(0); p=head2;while(p!=NULL)fwrite(p,sizeof(struct student),1,fp);p=p-next;fclose(fp); printf(学生信息已保存在%s中!n,filepath); void into()int i;printf(1.存储课程信息n);printf(2.存储学生信息n);

24、printf(3.返回主菜单n);printf(请输入(13)n);scanf(%d,&i);switch(i)case(1):intoc();break;case(2):intos();break;case(3):break; void store()int i;printf(tt系统信息查看及存储n);printf(1.查看课程信息n);printf(2.查看学生信息n);printf(3.存储信息n);printf(4.返回主菜单n);printf(请输入(14):n);scanf(%d,&i);switch(i)case(1):listc();break;case(2):lists()

25、;break;case(3):into();break;case(4):break;int main()int i;start:printf(nttt欢迎使用学生选课系统!n);printf(菜单:n);printf(1.录入课程信息n);printf(2.课程管理n);printf(3.录入学生信息n);printf(4.学生信息管理n);printf(5.学生选课n);printf(6.系统信息查看及存储n);printf(7.退出系统n);printf(n请输入菜单选项(17):n);scanf(%d,&i);if(i7)printf(输入错误,请重输:n);goto start;swi

26、tch(i)case(1):system(cls);inputc();goto start;break;case(2):system(cls);managementc();goto start;break;case(3):system(cls);inputs();goto start;break;case(4):system(cls);managements();goto start;break;case(5):system(cls);elective();goto start;break;case(6):system(cls);store();goto start;break;case(7):system(cls);printf(感谢使用本系统!nn再见!n);return(0);15ckwd2

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

当前位置:首页 > 社会民生


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