# Include "stdafx. h "# include <iostream> using namespace std; struct ListNode {int m_nValue; ListNode * m_pNext ;}; ListNode * ReverseList (ListNode * pListHead) {if (pListHead = NULL) {return NULL;} ListNode * pReverseHead = NULL; ListNode * pPre = NULL; ListNode * pNode = pListHead; ListNode * pNext = NULL; while (pNode! = NULL) {pNext = pNode-> m_pNext; if (pNext = NULL) {pReverseHead = pNode;} pNode-> m_pNext = pPre; pPre = pNode; pNode = pNext ;} return pReverseHead;} // create a linked list, enter the value of the Start Node and end node, and input-1 to end void CreateList (ListNode * & pHead) {ListNode * pListNode = NULL; listNode * pCurLastNode = NULL; bool isHead = true; while (1) {if (isHead) {pHead = new ListNode (); cin> pHead-> m_nValue; pHead-> m_pNext = NULL; isH Ead = false; pCurLastNode = pHead;} else {pListNode = new ListNode (); cin> pListNode-> m_nValue; if (pListNode-> m_nValue =-1) {break;} pListNode-> m_pNext = NULL; pCurLastNode-> m_pNext = pListNode; pCurLastNode = pListNode; }}// print the linked table void PrintList (ListNode * & pHead) from start to end) {if (pHead! = NULL) {ListNode * pCur = pHead; while (pCur! = NULL) {cout <pCur-> m_nValue <""; pCur = pCur-> m_pNext;} cout <endl;} else {cout <"linked list is empty! "<Endl ;}} int _ tmain (int argc, _ TCHAR * argv []) {ListNode * pListHead = NULL; CreateList (pListHead); PrintList (pListHead ); listNode * pReverseHead = ReverseList (pListHead); cout <pReverseHead-> m_nValue <endl; PrintList (pReverseHead); system ("pause"); return 0 ;} # include "stdafx. h "# include <iostream> using namespace std; struct ListNode {int m_nValue; ListNode * m_pNext ;}; ListNode * ReverseList (Li StNode * pListHead) {if (pListHead = NULL) {return NULL;} ListNode * pReverseHead = NULL; ListNode * pPre = NULL; ListNode * pNode = pListHead; listNode * pNext = NULL; while (pNode! = NULL) {pNext = pNode-> m_pNext; if (pNext = NULL) {pReverseHead = pNode;} pNode-> m_pNext = pPre; pPre = pNode; pNode = pNext ;} return pReverseHead;} // create a linked list, enter the value of the Start Node and end node, and input-1 to end void CreateList (ListNode * & pHead) {ListNode * pListNode = NULL; listNode * pCurLastNode = NULL; bool isHead = true; while (1) {if (isHead) {pHead = new ListNode (); cin> pHead-> m_nValue; pHead-> m_pNext = NULL; isHead = false; pCurLa StNode = pHead;} else {pListNode = new ListNode (); cin> pListNode-> m_nValue; if (pListNode-> m_nValue =-1) {break ;} pListNode-> m_pNext = NULL; pCurLastNode-> m_pNext = pListNode; pCurLastNode = pListNode ;}}// print the linked table void PrintList (ListNode * & pHead) {if (pHead! = NULL) {ListNode * pCur = pHead; while (pCur! = NULL) {cout <pCur-> m_nValue <""; pCur = pCur-> m_pNext;} cout <endl;} else {cout <"linked list is empty! "<Endl ;}} int _ tmain (int argc, _ TCHAR * argv []) {ListNode * pListHead = NULL; CreateList (pListHead); PrintList (pListHead ); listNode * pReverseHead = ReverseList (pListHead); cout <pReverseHead-> m_nValue <endl; PrintList (pReverseHead); system ("pause"); return 0 ;}