Saturday, June 18, 2005

Ordena de manera ascendente una matriz

/*
* Created on 06/18/2005
*
* Ordena de manera ascendente una matriz
*/
package estructura;

/**
* @author vns
*
*
*/
public class OrdenAsc {

/**
*
*/
public OrdenAsc() {
super();
}

public static void main(String[] args) {

}

public int[] ascendente(int[] temp){
int a = 0;
for (int i = 0; i < temp.length; i++) {
for (int j = 0; j < temp.length; j++) {
if (temp[j] > temp[j+1]) {
a = temp[j];
temp[j] = temp[j+1];
temp[j+1] = a;
}
}
}

return temp;
}

}

0 Comments:

Post a Comment

<< Home