C语言学生选课系统(代码)

上传人:re****.1 文档编号:499509159 上传时间:2022-10-02 格式:DOCX 页数:21 大小:25.78KB
返回 下载 相关 举报
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 * next;struct courseint num1;/ 课程编号char name120;char major20;char type20;int credit;int period;char teacher20;int people;/ 选此门课程的人数struct course *next;/ 结构体指针;struct course

2、* 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;whi

3、le(p1-num1!=0)N1=N1+1;if(N1=1)head1=p1;else p2-next=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-next=NULL;void zhang1()/ 从文件录入课程信息FILE * fp;char filepath20;struct course *p1,*p2;N

4、1=0;printf( 请输入您要读取的路径 :);getchar();gets(filepath);if(fp=fopen(filepath,r)=NULL).下载可编辑 .printf( 找不到%s 文件 !n,filepath);exit(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(fp)

5、N1=N1+1;if(N1=1)head1=p1;elsep2-next=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-next=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-next=NULL;elsewhile(p0-num1p1-num1) & (p1-next!=NULL)p2=p1;

7、p1=p1-next;if(p0-num1num1)if(head1=p1)head1=p0;elsep2-next=p0;.下载可编辑 .p0-next=p1;elsep1-next=p0;p0-next=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-next!=NULL)p2=p1;p1=p1-next;if(num1=p1-num1)if(p1=head1)head

8、1=p1-next;elsep2-next=p1-next;printf( 已删除 n);.下载可编辑 .N1=N1-1;elseprintf( 没有此课程 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(sizeof(s

9、truct 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;struc

10、t student *p1,*p2;N2=0;p1=p2=(struct student *)malloc(sizeof(struct student);printf( 学号 t姓名 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;elsep2-next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);scanf(%d%s,&p1-num

11、2,p1-name2);p1-nelen=0;for(i=0;inelenumi=0;p2-next=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);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;elsep2-next=p1;p2=p1;

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

当前位置:首页 > 办公文档 > 活动策划

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