Programa hecho en java, arreglo definido, donde sus valores son visualizados de forma inversa.

x.java

class CLASE
{
private int totalElementos;
private int elementos[];
int suma=0;
public CLASE(int elementos[], int totalElementos){
this.elementos=elementos;
this.totalElementos=totalElementos;
}
public void mostrardatos(){
System.out.print("LOS ELEMENTOS DEL ARREGLO SON :" );
for (int i=0; i
System.out.print(" " +elementos [i] );
}
void ordenarInverso(int elementos[], int totalElementos)
{
if (totalElementos>0)
{
System.out.print(" " +elementos[totalElementos-1]);
ordenarInverso(elementos, totalElementos-1);
}
}
}

public class x {
public x() {
}
public static void main(String[] args) {
int elementos[] = {0, 1, 2, 3, 4, 5, 6,7,8,15,20};
CLASE objeto = new CLASE(elementos, elementos.length);
objeto.mostrardatos();
System.out.println("");
System.out.println(" EL VECTOR INVERSO ES: ");
objeto.ordenarInverso(elementos, elementos.length);
}
}


Previous
Next Post »