#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N1,N2;
struct course
{
int num1; //课程编号
char name1[20];
int people; //选此门课程的人数
struct course *next; //结构体指针
};
struct student
{
int num2;
char name2[20];
int nelenum[50];//所选课程编号
struct student * next;
};
struct course * head1;
struct student * head2;
void insert(struct course *incourse) //增加课程信息
{
struct course *p0,*p1,*p2;
p1=head1;
p0=incourse;
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;
else
p2->next=p0;
p0->next=p1;
}
else
{
p1->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)
head1=p1->next;
else
p2->next=p1->next;
printf("已删除\n");
N1=N1-1;
}
else
printf("没有此课程\n");
end:;
}
#include<stdlib.h>
#include<string.h>
int N1,N2;
struct course
{
int num1; //课程编号
char name1[20];
int people; //选此门课程的人数
struct course *next; //结构体指针
};
struct student
{
int num2;
char name2[20];
int nelenum[50];//所选课程编号
struct student * next;
};
struct course * head1;
struct student * head2;
void insert(struct course *incourse) //增加课程信息
{
struct course *p0,*p1,*p2;
p1=head1;
p0=incourse;
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;
else
p2->next=p0;
p0->next=p1;
}
else
{
p1->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)
head1=p1->next;
else
p2->next=p1->next;
printf("已删除\n");
N1=N1-1;
}
else
printf("没有此课程\n");
end:;
}