回复 7楼 TonyDeng
我没抄啊,我是帮同学看的代码,估计是她在网上找的,不过有点不合实际啊,链表我们只讲过一节课,我都笑了,编这个
回复 6楼 yaobao
实现保存了??我咋连输入都停不下来???无语了
程序代码:
struct course *zhang() /*从键盘录入课程信息*/
{
char ch;
struct course *p1,*p2;
p1=p2=(struct course *)malloc(sizeof(struct course));
printf("C Numbers\tC name \tC nature\tcredits \tperiod\tteacher\n");
scanf("%d%s%s%d%d%s",&p1->num1,p1->name1,p1->type,&p1->credit,&p1->period,p1->teacher);
ch=getchar();
p1->people=0;
head1=NULL;
while(ch!=0x0b)
{
if(head1==NULL)
head1=p1;
else
p2->next=p1;
p2=p1;
p1=(struct course * )malloc(sizeof(struct course));
scanf("%d%s%s%d%d%s",&p1->num1,p1->name1,p1->type,&p1->credit,&p1->period,p1->teacher);
p1->people=0;
getchar();
ch=getchar();
}
}
