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

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

ID:47486664

大小:71.01 KB

页数:21页

时间:2020-01-12

C语言学生选课系统(代码)_第1页
C语言学生选课系统(代码)_第2页
C语言学生选课系统(代码)_第3页
C语言学生选课系统(代码)_第4页
C语言学生选课系统(代码)_第5页
资源描述:

《C语言学生选课系统(代码)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、#include#include#includeintN1,N2;structstudent{intnum2;charname2[20];intnelenum[50];//所选课程编号intnelen;//所选课程学分和structstudent*next;};structcourse{intnum1;//课程编号charname1[20];charmajor[20];chartype[20];intcredit;intperiod;charteacher[20];intpeople;//选此门课程的人数structcour

2、se*next;//结构体指针};structcourse*head1;structstudent*head2;voidzhang()//从键盘录入课程信息{structcourse*p1,*p2;N1=0;p1=p2=(structcourse*)malloc(sizeof(structcourse));21printf("课程编号t课程名称t主修t课程性质t学分t课时t教师");scanf("%d%s%s%s%d%d%s",&p1->num1,p1->name1,p1->major,p1->type,&p1->credit,&p1->period,p1->tea

3、cher);p1->people=0;head1=NULL;while(p1->num1!=0){N1=N1+1;if(N1==1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcourse*)malloc(sizeof(structcourse));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;}voidzhang1()//从文件录入课程信

4、息{FILE*fp;charfilepath[20];structcourse*p1,*p2;N1=0;printf("请输入您要读取的路径:");getchar();gets(filepath);if((fp=fopen(filepath,"r"))==NULL){21printf("找不到%s文件!",filepath);exit(0);}p1=p2=(structcourse*)malloc(sizeof(structcourse));fscanf(fp,"%d%s%s%s%d%d%s%d",&p1->num1,p1->name1,p1->major,p1->type,&

5、p1->credit,&p1->period,p1->teacher,&p1->people);while(!feof(fp)){N1=N1+1;if(N1==1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcourse*)malloc(sizeof(structcourse));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;}v

6、oidload()//录入课程信息函数{inti;printf("ttt录入课程信息");printf("1.从键盘录入");printf("2.从文件录入");printf("3.返回主菜单");printf("请选择1-3:");scanf("%d",&i);21switch(i){case1:zhang();break;case2:zhang1();break;case3:break;}}voidinsert(structcourse*incourse)//增加课程信息{structcourse*p0,*p1,*p2;p1=head1;p0=inco

7、urse;if(head1==NULL){head1=p0;p0->next=NULL;}else{while((p0->num1>p1->num1)&&(p1->next!=NULL)){p2=p1;p1=p1->next;}if(p0->num1<=p1->num1){if(head1==p1)head1=p0;elsep2->next=p0;p0->next=p1;21}else{p1->next=p0;p0->next=NULL;}}N1=N1+1;}void

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。