Implementar una aplicación que registre 10 números y que muestre posteriormente los números impares Ordenados En Forma Ascendente. Utilice Métodos De Ordenamiento.
Codigo Fuente:
import javax.swing.JOptionPane;
public class MetodosDeOrdenamiento {
public static void main(String [] args){
int vector[] = new int[10];
for(int i=0;i < vector.length;i++){
vector[i] = Integer.parseInt(JOptionPane.showInputDialog((i+1)+ "º Numero :",0));
}
String Cadena ="Numeros Sin Ordernar \n";
for(int i=0;i < vector.length;i++){
Cadena = Cadena + vector[i] + " ";
}
Insercion(vector);
Cadena = Cadena + "\nNumeros Impares Ordenados De Forma Ascendente";
for(int i=0;i < vector.length;i++){
if(vector[i]%2!=0){
Cadena = Cadena + "\n" + vector[i] ;
}
}
JOptionPane.showMessageDialog(null,Cadena);
}
public static void Insercion (int[] vector) {
for (int i=1; i < vector.length; i++) {
int aux = vector[i];
int j;
for (j=i-1; j > =0 && vector[j] > aux; j--){
vector[j+1] = vector[j];
}
vector[j+1] = aux;
}
}
}
Ejecucion Del Ejercicio!!
Segundo Ejercicio
Ingrese Nombres De Equipos de Futbol Con Su Respectivo Puntaje Visualizarlo Ordenados Por el Puntaje, Utilizando Métodos rápido Y Burbuja.
import javax.swing.JOptionPane;
public class MetodosDeOrdenamientoJugadores {
public static void main(String [] args){
int x =Integer.parseInt(JOptionPane.showInputDialog("Ingrese Total De Equipos",0));
int puntos[]= new int[x];
String equipos[]= new String[x];
for(int i =0;i < x;i++){
equipos[i]= JOptionPane.showInputDialog("Ingrese Nombre De Equipo" );
puntos[i]= Integer.parseInt(JOptionPane.showInputDialog("Ingrese Puntos",0));
}
Burbuja(puntos,equipos);
String Cadena = "Equipos Y Sus Puntos \n";
for(int i =0;i < x;i++){
Cadena = Cadena + equipos[i] + " " + puntos[i] + "\n";
}
JOptionPane.showMessageDialog(null, Cadena);
}
public static void Burbuja(int[]matrix,String[]equipos){
int temp;
String tempe;
for(int i=1;i < matrix.length;i++){
for (int j=0 ; j < matrix.length- 1; j++){
if (matrix[j] < matrix[j+1]){
temp = matrix[j];
matrix[j] = matrix[j+1];
matrix[j+1] = temp;
tempe = equipos[j];
equipos[j] = equipos[j+1];
equipos[j+1] = tempe;
}
}
}
}
//a = Inicio ; b = Final
public static void Rapido(int matrix[], int a, int b){
matrix = new int[matrix.length];
int buf;
int from = a;
int to = b;
int pivot = matrix[(from+to)/2];
do{
while(matrix[from] < pivot){
from++;
}
while(matrix[to] > pivot){
to--;
}
if(from < = to){
buf = matrix[from];
matrix[from] = matrix[to];
matrix[to] = buf;
from++; to--;
}
}while(from < = to);
if(a < to){
Rapido(matrix, a, to);
}
if(from < b){
Rapido(matrix, from, b);
}
}
}





Cuál es el burbuja?
ResponderEliminares el metodo de ordenamieno !
EliminarLas que se hacen con jabon. :v
ResponderEliminarWTF X'D
ResponderEliminarc mamo v:
ResponderEliminarexcelnte
ResponderEliminarEste comentario ha sido eliminado por el autor.
ResponderEliminarque método de ordenamiento es.?
ResponderEliminar