* struct ListNode {
 *	int val;
 *	struct ListNode *next;
 * };
 *
 * C语言声明定义全局变量请加上static,防止重复定义
 */

/**
 * 
 * @param pHead ListNode类 
 * @return ListNode类
 */
struct ListNode* ReverseList(struct ListNode* pHead ) {
    // write code here
    if(pHead == NULL)
        return NULL;
    struct ListNode *pT = pHead;
    
    struct ListNode *Head = pHead;
    while(Head->next != NULL)
    { 
        Head = Head->next;
    }
    while(pT->next != NULL)
    { 
        while(pT->next->next != NULL)
        { 
            pT = pT->next;
        }
        pT->next->next = pT;
        pT->next = NULL;
        
        pT = pHead;
        //pT = pT->next;
        
    }
    
    return Head;
}