chào mọi người, mọi người có thể giúp e xem lỗi gì không ạ hàm void ListQSort(TListElem* &list)

#include "stdafx.h"
#include <iostream>
using namespace std;

struct TListElem {
int Info;
TListElem *Next;
};

TListElem* CreateNode(int Data)
{
TListElem* pListElem;
pListElem = new TListElem;
if (pListElem == NULL)
return NULL;
pListElem->Info = Data;
pListElem->Next = NULL;
return pListElem;
}

bool AddHead(TListElem* &list, int Data)
{
TListElem *pListElem;
pListElem = CreateNode(Data);
if (pListElem == NULL)
list = pListElem;
else {
pListElem->Next = list;
list = pListElem;
}
return true;
}

//bool AddLast(TListElem* &list, int Data)
//{
// TListElem *pListElem;
// TListElem *p;
// pListElem = CreateNode(Data);
// if (list == NULL)
// list = pListElem;
// else {
// p = list;
// while (p->Next != NULL)
// {
// p = p->Next;
// }
// p->Next = pListElem;
// }
// return true;
//}

void PrintList(TListElem *list)
{
TListElem *pListElem;
pListElem = list;
while (pListElem != NULL)
{
cout << pListElem->Info << " ";
pListElem = pListElem->Next;
}
}

void ListQSort(TListElem* &list)
{
TListElem *p, *x, *last;
TListElem *list1, *list2;
TListElem *last1, *last2;
last = NULL;
if (list == last) return;
list1 = last1 = NULL;
list2 = last2 = NULL;
x = list;
list = list->Next;
x->Next = NULL;
while (list != NULL)
{
p = list;
list = list->Next;
p->Next = NULL;
if (p->Info <= x->Info)
AddHead(list1, p->Info);
else
AddHead(list2, p->Info);
}
ListQSort(list1);
ListQSort(list2);
if (list1 != NULL)
{
list = list1;
last1->Next = x;
}
else
list = x;
x->Next = list2;
if (list2 != NULL)
last = last2;
else
last = x;
}

int main()
{
TListElem *list;
list = NULL;
int Data;
do
{
cout << "Nhap vao du lieu: ";
cin >> Data;
if (Data == -1)
break;
AddHead(list, Data);
} while (Data != -1);
cout << "Du lieu da duoc nhap:\n";
PrintList(list);
cout << "\n";
cout << "Danh sach sau khi sap xep:\n";
ListQSort(list);
PrintList(list);
cout << "\n";
return 0;
}