# list链表构建和归并排序

#include<iostream>
#include<vector>

using namespace std;
struct ListNode {
int m_nValue;
ListNode *m_pNext;
ListNode(int x) : m_nValue(x), m_pNext(NULL) {}
};

{
ListNode * pNew = new ListNode(0);
pNew->m_nValue = value;
pNew->m_pNext = NULL;
{
}else
{
while(pNode->m_pNext!=NULL)
{
pNode = pNode->m_pNext;
}
pNode->m_pNext = pNew;
}
}

{
int size = list_val.size();
for(int i=0;i<size; i++)
{

cout<<"input:"<<list_val[i]<<endl;
}
}

{
int i ;
for(i = 0 ; head ; i++)
return i;
}

for(int i=0; i<k; i++)
{
}
}

ListNode * Merge(ListNode *list1, ListNode *list2)
{
if(list1==NULL) return list2;
if(list2==NULL) return list1;
if(list1==NULL&&list2==NULL) return NULL;
ListNode *ret;
ret = list1->m_nValue <= list2->m_nValue ? list1 : list2;
ret->m_pNext = list1->m_nValue <= list2->m_nValue ? Merge(list1->m_pNext, list2) : Merge(list1, list2->m_pNext);
return ret;
}

{
cout<<"================="<<endl;
while(pNode!=NULL)
{
cout<<pNode->m_nValue<<endl;
pNode = pNode->m_pNext;
}
}

{
int length = GetListSize(pNode);
if(length<=1) return pNode;
ListNode * ptr = Access_K(pNode, length/2-1);
ListNode * list1 = SortList(ptr->m_pNext);
PrintList(list1);
ptr->m_pNext = NULL;
ListNode * list2 = SortList(pNode);
PrintList(list2);
return Merge(list1, list2);
}

int main(int argc, char *argv[])
{
vector<int> list_val ;
list_val.push_back(1);
list_val.push_back(2);
list_val.push_back(5);
list_val.push_back(2);
list_val.push_back(3);
list_val.push_back(1);
list_val.push_back(6);
list_val.push_back(9);
list_val.push_back(0);
}