代码语言:javascript复制
int PartSort(int* array,int left,int right)
{
int& key = array[right];
while(left < right)
{
while(left < right && array[left] <= key)
{
left;
}
while(left < right && array[right] >= key)
{
--right;
}
swap(array[left],array[right]);
}
swap(array[left],key);
return left;
}
反转链表也纹在手上吧
代码语言:javascript复制ListNode* ReverseList(ListNode* pHead)
{
ListNode* pReversedHead = NULL;
ListNode* pNode = pHead;
ListNode* pPrev = NULL;
while(pNode != NULL)
{
ListNode* pNext = pNode->m_pNext;
if(pNext == NULL)
pReversedHead = pNode;
pNode->m_pNext = pPrev;
pPrev = pNode;
pNode = pNext;
}
return pReversedHead;
}