链表型(Node泛型)数组,每一个元素代表一条链表,称为桶。我用了19个桶 是为了在排序有负数时也可以正常排序。因为java对一个负数求余数也是负数, 这就导致了在求一个负数的某一位时得到的也为负数,所以对他进行加9的处理变 为非负数,对正数也是加9处理,所以有-9存0号桶,9存19号桶。这样正负数就 都能排序了。 public class Radixsort { private static class Node<Integer>{ int element; private Node<Integer> next; private Node(int element, Node<Integer> next){ this.element = element; this.next = next; } } void addlast(Node<Integer> n,Node<Integer> m) { if(n==null) n=m; if(n!=null) { Node<Integer> nod=n; while(nod.next!=null) { nod=nod.next; } nod.next=m; } } public void sort(int[] n,int d) { int lon=n.length;//链表长度