class Node{ int value; Node next; public Node(){} public Node(int value){ this.value=value; } }public class Main{ public static void main(String[] args){ Node node = new Node(1); node.next=new Node(2); node.next.next=new Node(3); Node node1 = resvlor(node); while(node1!=null){ System.out.println(node1.value); node1=node1.next; } } public static Node resvlor(Node head){ if(head==null||head.next==null){ return head; } Node newNode=resvlor(head.next); head.next.next=head; head.next=null; return newNode; }
04-03
1813