#include "stdafx.h"
#include <iostream>
#include <string>
#include <tchar.h>
using namespace std;
struct sigList {
int value;
sigList *pNext;
};
sigList* pHead = NULL;
sigList* p1 = NULL;
sigList* p2 = NULL;
sigList* pc = NULL;
void addValue(int value) {
sigList* pNewValue = new sigList;
pNewValue->pNext = NULL;
pNewValue->value = value;
if (NULL == pHead) {
pHead = pNewValue;
pc = pHead;
}
pc->pNext = pNewValue;
pc = pNewValue;
}
void ReSort() {
p1 = pHead;
p2 = pHead->pNext;
p1->pNext = NULL;
pc = p1;
while ( NULL != p2)
{
p1 = p2;
p2 = p2->pNext;
p1->pNext = pc;
pc = p1;
}
pHead = pc;
}
void PrintList()
{
p1 = NULL;
p1 = pHead;
while (NULL != p1)
{
cout << p1->value << endl;
p1 = p1->pNext;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
addValue(1);
addValue(2);
addValue(3);
addValue(4);
addValue(5);
cout << "Add" << endl;
PrintList();
ReSort();
cout << "Resort" << endl;
PrintList();
return 0;
}