/**
* @author zhouwei
* @Description: TODO
* @create 2018-11-05 下午8:31
**/
public class A {
public static void main(String[] args) {
Node d = new Node(null, 4);
Node c = new Node(d, 3);
Node b = new Node(c, 2);
Node a = new Node(b, 1);
Node res = reSubStr(a, a);
while (res != null) {
System.out.println(res.value);
res = res.next;
}
}
static class Node {
Node next;
int value;
public Node(Node node, int value) {
this.next = node;
this.value = value;
}
}
private static Node reSubStr(Node head, Node tail) {
if (tail.next != null) {
Node c = tail.next.next;
Node b = tail.next;
b.next = head;
tail.next = c;
head = reSubStr(b, tail);
}
return head;
}
}