1 #include "stdafx.h" 2 #include <iostream> 3 4 using namespace std; 5 struct ListNode 6 { 7 int m_nValue; 8 ListNode* m_pNext; 9 }; 10 11 void AddToTail(ListNode** pHead,int value) 12 { 13 ListNode* pNew=new ListNode(); 14 pNew->m_nValue=value; 15 pNew->m_pNext=NULL; 16 if(pHead==NULL) 17 { 18 *pHead=pNew; 19 }else 20 { 21 ListNode* pNode = *pHead; 22 23 while(pNode->m_pNext!=NULL) 24 { 25 pNode=pNode->m_pNext; 26 } 27 pNode->m_pNext=pNew; 28 } 29 }