C语言学生选课系统代码

上传人:mg****2 文档编号:269179214 上传时间:2022-03-22 格式:DOC 页数:21 大小:45KB
返回 下载 相关 举报
C语言学生选课系统代码_第1页
第1页 / 共21页
C语言学生选课系统代码_第2页
第2页 / 共21页
C语言学生选课系统代码_第3页
第3页 / 共21页
C语言学生选课系统代码_第4页
第4页 / 共21页
C语言学生选课系统代码_第5页
第5页 / 共21页
点击查看更多>>
资源描述

《C语言学生选课系统代码》由会员分享,可在线阅读,更多相关《C语言学生选课系统代码(21页珍藏版)》请在金锄头文库上搜索。

1、-#include#include#includeint N1,N2;struct studentint num2; char name220; int nelenum50; /所选课程编号 int nelen; /所选课程学分和 struct student * ne*t;struct courseint num1; /课程编号char name120; char major20;char type20;int credit;int period;char teacher20;int people; /选此门课程的人数struct course *ne*t; /构造体指针;struct co

2、urse * head1;struct student * head2;void zhang() /从键盘录入课程信息struct course *p1,*p2; N1=0; p1=p2=(struct course *)malloc(sizeof(struct course); printf(课程编号t课程名称t主修t课程性质t学分t课时t教师n); scanf(%d%s%s%s%d%d%s,&p1-num1,p1-name1,p1-major,p1-type,&p1-credit,&p1-period,p1-teacher); p1-people=0; head1=NULL; while(

3、p1-num1!=0)N1=N1+1; if(N1=1)head1=p1; else p2-ne*t=p1; p2=p1; p1=(struct course * )malloc(sizeof(struct course); scanf(%d%s%s%s%d%d%s,&p1-num1,p1-name1,p1-major,p1-type,&p1-credit,&p1-period,p1-teacher); p1-people=0; p2-ne*t=NULL;void zhang1() /从文件录入课程信息FILE * fp; char filepath20; struct course *p1,

4、*p2; N1=0; printf(请输入您要读取的路径:); getchar(); gets(filepath); if(fp=fopen(filepath,r)=NULL)printf(找不到 %s 文件!n,filepath); e*it(0); p1=p2=(struct course*)malloc(sizeof(struct course); fscanf(fp,%d%s%s%s%d%d%s%d,&p1-num1,p1-name1,p1-major,p1-type,&p1-credit,&p1-period,p1-teacher,&p1-people); while(!feof(f

5、p)N1=N1+1; if(N1=1)head1=p1; else p2-ne*t=p1; p2=p1; p1=(struct course * )malloc(sizeof(struct course); fscanf(fp,%d%s%s%s%d%d%s%d,&p1-num1,p1-name1,p1-major,p1-type,&p1-credit,&p1-period,p1-teacher,&p1-people); p2-ne*t=NULL;void load() /录入课程信息函数int i;printf(ttt录入课程信息n);printf(n1.从键盘录入);printf(n2.从文

6、件录入);printf(n3.返回主菜单n);printf(请选择1-3:);scanf(%d,&i);switch(i)case 1: zhang(); break; case 2:zhang1();break; case 3:break; void insert(struct course *incourse) /增加课程信息struct course *p0,*p1,*p2; p1=head1; p0=incourse; if(head1=NULL)head1=p0; p0-ne*t=NULL; elsewhile(p0-num1p1-num1) & (p1-ne*t!=NULL)p2=

7、p1; p1=p1-ne*t; if(p0-num1num1)if(head1=p1)head1=p0; elsep2-ne*t=p0; p0-ne*t=p1; elsep1-ne*t=p0; p0-ne*t=NULL; N1=N1+1;void delc(int num1) /删除课程信息struct course *p1,*p2; if(head1=NULL)printf(n无法删除!n); goto end; p1=head1; while(num1!=p1-num1 & p1-ne*t!=NULL) p2=p1; p1=p1-ne*t; if(num1=p1-num1)if(p1=he

8、ad1) head1=p1-ne*t; else p2-ne*t=p1-ne*t; printf(已删除n); N1=N1-1; else printf(没有此课程n); end:;void managementc() /课程信息管理函数struct course * p1; int i,num1; printf(ttt课程信息管理n); printf(1.添加课程n); printf(2.删除课程n); printf(3.返回n); printf(请输入1-3:n); scanf(%d,&i); switch(i) case 1:p1=(struct course *)malloc(size

9、of(struct course);printf(课程编号t课程名称t主修t课程性质t学分t课时t教师n); scanf(%d%s%s%s%d%d%s,&p1-num1,p1-name1,p1-major,p1-type,&p1-credit,&p1-period,p1-teacher);p1-people=0;insert(p1); break;case 2:printf(请输入您要删除的课程编号:n);scanf(%d,&num1);delc(num1); break;case 3:break;void putin(void) /从键盘录入学生信息 int i;struct student

10、 *p1,*p2;N2=0;p1=p2=(struct student *)malloc(sizeof(struct student);printf(*tn);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-ne*t=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);scanf(%d%s,&p1-num2,p1-name2);p1

11、-nelen=0;for(i=0;inelenumi=0;p2-ne*t=NULL;void putin2() /从文件录入学生信息int i=0;FILE * fp;char filepath20;struct student *p1,*p2;N2=0;printf(请输入您要读取的路径:);getchar();gets(filepath);if(fp=fopen(filepath,rt)=NULL)printf(找不到 %s 文件!n,filepath);e*it(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;else p2-ne*t=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);fread(p1,sizeof(struct s

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号