填空题 已知h1和h2为两个单向链表的头指针,h1指向的链表不为空链表。add函数的功能是将h2指向的链表(简称h2链表)中全部结点插入到h1指向的链表(简称h1链表)中第n个结点(n>0)之后,如果h2链表为空链表,则函数直接返回h1链表首结点的地址。如果h1链表中不存在第n个结点,则将h2链表中全部结点添加到h1链表的末尾,函数返回h1链表首结点地址.链表结点采用如下形式的数据结构: struct node { int data; struct node *next; }; #include struct node *add(struct node *h1,struct node *h2,int n) {struct node *p1=h1,*q=h2,*p2; int i=0; if(h2== 1(27) 2) return h1; p2=h1; while(p1&&inext; 3(28) 4; } if(inext=q; else { 5(29) 6=q; while(q->next) q=q->next; q->next= 7(30) 8; } return h1; }
  • 1、
【正确答案】 1、(27)NULL (28)i=i+1 (29)p2->next (30)p1    
【答案解析】