合并两个有序的单链表:
1.创建两个有序的单链表;
2.创建第三个链表来存放合并后的有序链表;
#include
using namespace std;
struct ListNode{
int value;
ListNode* next;
};
class CreateList
{
typedef ListNode Node;
public:
CreateList()
:pHead(NULL)
{}
void push(int _value)
{
Node* tp = pHead;
Node* temp = new Node();
if (!pHead)
{
pHead = temp;
pHead->value = _value;
pHead->next = NULL;
}
else
{
while (tp->next)
{
tp = tp->next;
}
tp->next = temp;
temp->value =_value;
temp->next = NULL;
}
}
Node* Combin