递归/*
struct ListNode {
int val;
struct ListNode *next;ListNode(int x) :
val(x), next(NULL) {
}
};*/
class Solution {
public:
ListNode* Merge(ListNode* pHead1, ListNode* pHead2)
{
if(pHead1==NULL)
return pHead2;
else if(pHead2==NULL)
return pHead1;
ListNode* p1=pHead1;
ListNode* p2=pHead2;
ListNode* newHead=NULL;
if(p1->val<p2->val){
newHead=p1;
newHead->next=Merge(p1->next,p2);
}
else{
newHead=p2;
newHead->next=Merge(p2->next,p1);
}
return newHead;
}
};