0
public  void ordenacionShaker(int[] v) {
    final int N = v.length;
    int limInferior = 0;
    int limSuperior = N-1;
    while(limInferior <= limSuperior) {
        for(int j=limInferior; j<limSuperior; j++) {
            if(v[j]>v[j+1]) {
                int tmp = v[j];
                v[j]    = v[j+1];
                v[j+1]  = tmp;
            }
        }
        limSuperior--;
        for(int j=limSuperior;j>limInferior; j--) {
            if(v[j]<v[j-1]) {
                int tmp = v[j];
                v[j]    = v[j-1];
                v[j-1]  = tmp;
            }
        }
        limInferior++;
    }
}
0

1 respuesta 1

0

Intenta invirtiendo los operadores ">" "<" en tus condiciones si tienes un ">" cambialo por un "<" y viceversa.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.