阅读以下函数说明和C语言函数,将应填入(n)处的字句写在对应栏内。
[说明]
该程序从正文文件test.txt中读入一批整数,并将它们按照递增的顺序存放在一个链表中。其中,函数struct Link*insertChain(struct Link*head,structLink*k)用来寻找结点k在链表head中的插入位置,并插入该结点。
[C程序]
#include <stdio.h>
#include <stdlib.h>
struct Link
{ int number;
struct Link *next;
}
struct Link *insertChain(struct Link *head,struct Link *k);
VOid main()
{ struct Link *ptr, *head;
FILE *fd;
int hum;
if((fd=fopen("test.txt","r"))==NULL)
{print("Cannot open this file!\n");
return;
}
head=NULL;
while(fscanf(fd,"%d",hum)==1)
{ ptr=(1);
if(!ptr) return;
ptr->number=hum;
ptr->next=NULL;
head=insertChain(head,ptr);
}
(2);
return;
}
struct Link *insertChain(struct Link *head,struct Link *k)
{ struct Link *ptr,*u;
ptr=head;
while(ptr && k && k->number>ptr->number)
{ u=ptr; (3) }
if(ptr == head) head=k;
else (4);
(5);
return head;
}
订单号:
遇到问题请联系在线客服
订单号:
遇到问题请联系在线客服