安阳烘培加工厂招工:数据链表问题!添加数据

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/09 11:56:04
请各位大侠帮帮我吧!!
呵呵!1谢谢哦!!添加数据:该功能可允许用户输入一个新同学的学号及成绩,如果在链表中已存在相同学号的同学,则给出错误提示信息,否则将它加在原有链表的尾部。
使用C语言编写:请各位大侠帮帮我吧!!
呵呵!1谢谢哦!!添加数据:该功能可允许用户输入一个新同学的学号及成绩,如果在链表中已存在相同学号的同学,则给出错误提示信息,否则将它加在原有链表的尾部。
我同学编了一点,请大家指教!
struct student * insert (struct student * head,struct student * stud)
{struct student
{long num;
float score;
}
struct student stud_1;
stud_1.num=050824201;
stud_1.score=90;
printf("NO.%ld\nnum:%c\nscore:%f\n",stud_1.num,stud_1.score);

}
int n,num,next;
{struct student *p0,*p1,*p2;
p1=head;
p0=stud;
if(head==NULL)
{head=p0;p0->next=NULL;}
else
{ while((p0->num>p1->num)&&(p1->next!=NULL))
{p2=p1;
p1=p1->next;}
if(p0->num<=p1->num)
{if(head==p1) head=p0;
else p2->next=p0;
p0->next=p1;}
else
{p1->next=p0;p0->next=NULL;}
}
n=n+1;
return(head);
}

你用什么语言写的阿?说的问题太简单了,估计没有人能回答得了你的问题的。建议补充说明问题