100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 学生选课系统c语言程序总结 学生选课系统C语言程序代码总结.doc

学生选课系统c语言程序总结 学生选课系统C语言程序代码总结.doc

时间:2022-12-21 01:40:55

相关推荐

学生选课系统c语言程序总结 学生选课系统C语言程序代码总结.doc

#include

#include

struct couse * head1;

struct student * head2;

struct couse//课程信息结构体

{

int num1;

char name1[20];

int score;

int nelepeo;//课程已选人数

int Melepeo;//课程人数上限

struct couse * next;

};

struct student//学生信息结构体

{

int num2;

char name2[20];

int nelenum[50];//已选课程编号

int nelen;//已选课程数量

struct student * next;

};

void keyboardc()//录入课程子函数(从键盘录入)

{

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->num1,p1->name1,&p1->score,&p1->Melepeo);

p1->nelepeo=0;

head1=NULL;

while(p1->num1!=0&&p1->num1!='#')

{

N1=N1+1;

if(N1==1)head1=p1;

else p2->next=p1;

p2=p1;

p1=(struct couse * )malloc(sizeof(struct couse));

scanf("%d%s%d%d",&p1->num1,p1->name1,&p1->score,&p1->Melepeo);

p1->nelepeo=0;

}

p2->next=NULL;

}

void inputc()//录入课程主函数

{

int i;

printf("\n录入课程信息\n");

printf("\n1.从键盘录入\n");

printf("\n2.返回主菜单\n");

printf("\n请选择编号(1~3):\n");

scanf("%d",&i);

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->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 couse *p1,*p2;

if(head1==NULL)

{

printf("\n没有课程,无法删除!\n");

goto end;

}

p1=head1;

while(num1!=p1->num1 && p1->next!=NULL)

{

p2=p1;

p1=p1->next;

}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。