1、#include #includestruct couse * head1;struct student * head2;struct couse/课程信息结构体int num1;char name120;int score;int nelepeo;/课程已选人数int Melepeo;/课程人数上限struct couse * next;struct student/学生信息结构体int num2;char name220;int nelenum50;/已选课程编号int nelen;/已选课程数量struct student * next;void keyboardc()/录入课程子函数(
2、从键盘录入)struct couse *p1,*p2;N1=0;p1=p2=(struct couse*)malloc(sizeof(struct couse);printf(“n 课程编号 t 课程名称t 学分t 课程人数上限n“);scanf(“%d%s%d%d“,p1-nelepeo=0;head1=NULL;while(p1-num1!=0if(N1=1)head1=p1;else p2-next=p1;p2=p1;p1=(struct couse * )malloc(sizeof(struct couse);scanf(“%d%s%d%d“,p1-nelepeo=0;p2-next=
3、NULL;void inputc()/录入课程主函数int i;printf(“n 录入课程信息 n“);printf(“n1.从键盘录入 n“); printf(“n2.返回主菜单 n“);printf(“n 请选择编号 (13):n“);scanf(“%d“, switch(i)case(1):keyboardc();break;case(2):break;void insertc(struct couse *incouse)/课程信息增加子函数struct couse *p0,*p1,*p2;p1=head1;p0=incouse;if(head1=NULL)head1=p0;p0-ne
4、xt=NULL;elsewhile(p0-num1p1-num1)p1=p1-next;if(p0-num1 num1)if(head1=p1) head1=p0;else p2-next=p0;p0-next=p1;elsep1-next=p0;p0-next=NULL;N1=N1+1;void delc(int num1)/课程信息删除子函数struct couse *p1,*p2;if(head1=NULL)printf(“n 没有课程 ,无法删除!n“);goto end;p1=head1;while(num1!=p1-num1 p1=p1-next;if(num1=p1-num1)i
5、f(p1=head1) head1=p1-next;else p2-next=p1-next;printf(“n 已删除该编号课程 !n“);N1=N1-1;else printf(“n 无该编号的课程 !n“);end:;void managementc()/课程信息管理主函数struct couse * incouse;int i,num1;printf(“n 课程管理 n“);printf(“n1.新增课程 n“);printf(“n2.删除课程 n“);printf(“n3.返回主菜单 n“);printf(“n 请选择编号 (13):n“);scanf(“%d“,switch(i)c
6、ase(1):incouse=(struct couse *)malloc(sizeof(struct couse);printf(“n 课程编号t 课程名称 t 学分t 课程人数上限n“);scanf(“%d%s%d%d“,incouse-nelepeo=0;insertc(incouse);break;case(2):printf(“n 请输入要删除课程的编号:n“);scanf(“%d“,delc(num1);break;case(3):break;void keyboards()/录入学生信息子函数(从键盘录入)int i;struct student *p1,*p2;N2=0;p1=
7、p2=(struct student *)malloc(sizeof(struct student);printf(“n 学生学号 t 学生姓名n“);scanf(“%d%s“,p1-nelen=0;for(i=0;inelenumi=0;head2=NULL;while(p1-num2!=0)N2=N2+1;if(N2=1)head2=p1;else p2-next=p1;p2=p1;p1=(struct student * )malloc(sizeof(struct student);scanf(“%d%s“,p1-nelen=0;for(i=0;inelenumi=0;p2-next=N
8、ULL;void inputs()/录入学生信息主函数int i;printf(“n 录入学生信息 n“);printf(“n1.从键盘录入 n“);printf(“n2.返回主菜单 n“);printf(“n 请选择编号 (12):n“);scanf(“%d“,switch(i)case(1):keyboards();break;case(2):break;void inserts(struct student * incouse)/学生信息增加子函数struct student *p0,*p1,*p2;p1=head2;p0=incouse;if(head2=NULL)head2=p0;p0-next=NULL;elsewhile(p0-num2 p1-num2) p1=p1-next;if(p0-num2 num2)if(head2=p1) head2=p0;else p2-next=p0;p0-next=p1;elsep1-next=p0;p0-next=NULL;N2=N2+1;void dels(int num2)/学生信息删除子函数struct student *p1,*p2;