Você está na página 1de 1

/** * Julio Cesar Resendiz Ramirez */ public class ShellShort { public static void ordenacionShell(int[] v) { final int N = v.

length; int incremento = N; do { incremento = incremento / 2; for (int k = 0; k < incremento; k++) { for (int i = incremento + k; i < N; i += incremento) { int j = i; while (j - incremento >= 0 && v[j] < v[j - incremento]) { int tmp = v[j]; v[j] = v[j - incremento]; v[j - incremento] = tmp; j -= incremento; } } } } while (incremento > 1); } } public class ProyectoShellSohrt { public static void main(String[] args) { // TODO code application logic here int [] valores = {98,17,8,3,45,1,10,56,34,7,20}; ShellShort.ordenacionShell(valores); for (int i = 0; i < valores.length ; i++) System.out.println ( "valores["+i+"]: "+ valores[i]); } }

Você também pode gostar