# 单向链表逆序

```#include <iostream>
using namespace std;

typedef struct ListNode{
int data;
struct ListNode* next;
}*List;
int main()
{
for (int i=1;i<10;i++)
{
q=new ListNode;
q->data=i;
q->next=NULL;
p->next=q;
p=q;
}
printList(back);
system("pause");
return 0;
}

{
List next,prev=NULL;

{
}
return prev;

}

{

{
}
cout<<endl;

}```

## 华为机试题-- 单链表逆序

[问题] 单链表逆序 [代码] #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct ListNode { int value; struct ListNode *next; }ListNode; typedef struct ListNode *List; List reverseList(List head) //列表逆序 { ListNode *rear, *curr,

## 两种方法求单链表逆序

1 递归,非常easy 代码: #include<iostream> using namespace std; typedef struct node{ int data; struct node * pNext; }Node ,*pNode; void createNode(pNode & pHead){ int temp; scanf("%d",&temp); pNode p,q; bool isFirst = true; while(temp){ if

## 链表逆序

private void ListResverse(ListNode head) { ListNode cur,next; if(head == null||head.next == null) return; cur = head.next; while(cur.next!=null) { next = cur.next; cur.next = next.next; next.next = cur; head.next = next; } }

## reverse list链表逆序

1 ListNode* reverseList(ListNode* head){ 2 if (head==NULL || head->next==NULL) return head; 3 ListNode *pre=head, *cur=pre->next, *post; 4 pre->next = NULL; 5 while (cur!=NULL){ 6 post = cur->next; 7 cur->next = pre; 8 pre = cur; 9 cur = po