1) 函数merge(intNode *a, intNode *b)将两个升序链表a和b合并成一个升序链表并返回指针。
typedef struct element
{
int val;
struct element *next;
}intNode;
intNode *merge(intNode *a, intNode *b)
{
intNode * h= a; *p, *q;
while(b)
{
for(p=h;p&&p->val<b->val; q=p; p=p->next);
if(p==h)__(1)____;
else __(2)_____;
q=b; b=b->next;
___(3)___;
}
return h;
}
提示: 将b的每个元素依次插入a中
答案:
1 h=b;
2 q->next = b;
3 q->next = p;