资源描述:
《学生选课系统c语言程序代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#includestructcouse*head1;structstudent*head2;structcouse//课程信息结构体{intnum1;charname1[20];intscore;intnelepeo;//课程已选人数intMelepeo;//课程人数上限structcouse*next;};structstudent//学生信息结构体{intnum2;charname2[20];intnelenum[50];//已选课程编号intnelen;//已选课程数量st
2、ructstudent*next;};voidkeyboardc()//录入课程子函数(从键盘录入){structcouse*p1,*p2;N1=0;p1=p2=(structcouse*)malloc(sizeof(structcouse));printf("课程编号t课程名称t学分t课程人数上限");scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1->Melepeo);p1->nelepeo=0;head1=NULL;while(p1->num1!=0&&p1-
3、>num1!='#'){N1=N1+1;if(N1==1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcouse*)malloc(sizeof(structcouse));scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1->Melepeo);p1->nelepeo=0;}p2->next=NULL;}voidinputc()//录入课程主函数{inti;printf("录入课程信息");printf("1.从键盘录入");pr
4、intf("2.返回主菜单");printf("请选择编号(1~3):");scanf("%d",&i);switch(i){case(1):keyboardc();break;case(2):break;}}voidinsertc(structcouse*incouse)//课程信息增加子函数{structcouse*p0,*p1,*p2;p1=head1;p0=incouse;if(head1==NULL){head1=p0;p0->next=NULL;}else{while((p0->num1>p1->num1
5、)&&(p1->next!=NULL)){p2=p1;p1=p1->next;}if(p0->num1<=p1->num1){if(head1==p1)head1=p0;elsep2->next=p0;p0->next=p1;}else{p1->next=p0;p0->next=NULL;}}N1=N1+1;}voiddelc(intnum1)//课程信息删除子函数{structcouse*p1,*p2;if(head1==NULL){printf("没有课程,无法删除!");gotoend;}p1=head1;while(
6、num1!=p1->num1&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num1==p1->num1){if(p1==head1)head1=p1->next;elsep2->next=p1->next;printf("已删除该编号课程!");N1=N1-1;}elseprintf("无该编号的课程!");end:;}voidmanagementc()//课程信息管理主函数{structcouse*incouse;inti,num1;printf("课程管理");print
7、f("1.新增课程");printf("2.删除课程");printf("3.返回主菜单");printf("请选择编号(1~3):");scanf("%d",&i);switch(i){case(1):{incouse=(structcouse*)malloc(sizeof(structcouse));printf("课程编号t课程名称t学分t课程人数上限");scanf("%d%s%d%d",&incouse->num1,incouse->name1,&incouse->score,
8、&incouse->Melepeo);incouse->nelepeo=0;insertc(incouse);break;}case(2):{printf("请输入要删除课程的编号:");scanf("%d",&num1);d