总体思路:其实就是将原链表结点关系解除,然后逆向拼接
思路
- 建立前置和后置指针pr和temp,pr=NULL,temp=p->next。
- 让中间指针分别指向前置和后置指针。
- 前置指针指向中间指针,中间指针指向后置指针,直到中间指针指向空。
- 让原头结点L->next指向前指针pr。
/*输入1 2 3 4 5 6 7 8 9 0
遇到0时结束输入*/
#include <iostream>
using namespace std;
typedef struct LNode
{
int data