资源描述:
《学生选课系统代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#includeintN1,N2,kk1,kk2,kk3;structcouse*head1;structstudent*head2;structcouse{intnum1;charname1[20];intscore;intnelepeo;intMelepeo;structcouse*next;};structstudent{intnum2;charname2[20];intnelenum[50];intnelen;structstudent*next;}
2、;voidMs(){for(kk1=0;kk1<1100;kk1++)for(kk2=0;kk2<1200;kk2++)for(kk3=0;kk3<1200;kk3++);}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,
3、&p1->Melepeo);p1->nelepeo=0;head1=NULL;while(p1->num1!=0){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;}voidfilec(){FIL
4、E*fp;charfilepath[20];structcouse*p1,*p2;N1=0;printf("输入要读入的文件路径:");getchar();gets(filepath);if((fp=fopen(filepath,"r"))==NULL){printf("找不到%s文件!",filepath);exit(0);}p1=p2=(structcouse*)malloc(sizeof(structcouse));fscanf(fp,"%d%s%d%d%d",&p1->num1,p1->name1,
5、&p1->score,&p1->nelepeo,&p1->Melepeo);head1=NULL;while(!feof(fp)){N1=N1+1;if(N1==1)head1=p1;elsep2->next=p1;p2=p1;p1=(structcouse*)malloc(sizeof(structcouse));fscanf(fp,"%d%s%d%d%d",&p1->num1,p1->name1,&p1->score,&p1->nelepeo,&p1->Melepeo);}p2->next=NULL;}vo
6、idinputc(){inti;printf("ttt录入课程信息");printf("1.从键盘录入");printf("2.从文件录入");printf("3.返回主菜单");printf("请选择(1~3):");scanf("%d",&i);switch(i){case(1):keyboardc();break;case(2):filec();break;case(3):break;}}voidinsertc(structcouse*incouse){structcouse
7、*p0,*p1,*p2;p1=head1;p0=incouse;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;}else{p1->next=p0;p0->next=NULL;}}N1=N1+1;}v
8、oiddelc(intnum1){structcouse*p1,*p2;if(head1==NULL){printf("没有课程,无法删除!");gotoend;}p1=head1;while(num1!=p1->num1&&p1->next!=NULL){p2=p1;p1=p1->next;}if(num1==p1->num1){if(p1==head1)head1=p1->