Algorithms are purely personal hobbies, welcome to exchange, sharing
/** * */package com.zimo.sequence;/** * Reverse order * @author Sub-ink * * 2015-3-11 PM 2:31:55 */public class Node {int data; Node Next = null;public node (int data) {This.data=data;} /** * 1->2->3->4->5->6->7->8->9 * defines a p * 1. Take 1, pay P * 2. Take 2,2->1 * 3. Go to 3,3->2->1 and so on. @param head * @return */public static node reverse (node Head) {node p = null; Node q = head; while (head.next!=null) {p = Head.next;head.next = P.next;p.next = Q;q = p;} return q; }/** * @param args */public static void main (string[] args) {node head = new Node (0); Node node = head;/** * Assigns a value to node * 1->2->3->4->5->6->7->8->9 */for (int i = 1; i <; ++i) {node n = new Node (i); node.next = N;node = N; System.out.println (N.data); }head = Reverse (head), while (head.next! = null) {System.out.println (head.data); head = Head.next;}}}
List of algorithms in reverse order