/**
* struct ListNode {
* int val;
* struct ListNode *next;
* };
*/
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param head ListNode类
* @return ListNode类
*/
//链表玩的就是怎么插指针的问题,很简单,每次找到自己需要的指针,根据题意插即可。
//Newnode创建了一个新头,n1就是拿要用的当前指针,n2就是下一个要用的指针.
struct ListNode* ReverseList(struct ListNode* head ) {
if(head == NULL){
return NULL;
}
struct ListNode* Newnode = NULL;
struct ListNode* n1 = head;
struct ListNode* n2 = head->next;
while(n1){
n1->next = Newnode;
Newnode = n1;
n1 = n2;
if(n2){
n2 = n2->next;
}
}
return Newnode;
}