Search()函数
struct linknode *Search(struct linknode *head,int n)
{
int i=1;
struct linknode *p=head;
for(p=head;p!=NULL;p=p->next,i++)
if(i==n)
break;
if(i<n)
return NULL;
else
return p;
}
查找函数,但是有一个疑问没能解决:在第一行中为什么 *Search前要加星号?
insert函数
void insert(struct linknode *p,struct linknode *r)
{
r->next=p->next;
p->next=r;
}
插入函数
Delete函数
void Delete(struct linknode *p)
{
struct linknode *q;
q=p->next;
p->next=q->next;
free(q);
}
删除函数
Display函数
void Display(struct linknode *head)
{
struct linknode *p;
for(p=head;p!=NULL;p=p->next)
printf(“Num: %d,Score: %f\n”,p->no,p->score);
}
输出函数,有个疑问:是不是没输出一个数,这个数的空间就被释放了,所以才有了第四行的代码p=p->next?