ArregloUnidimensional 20410

Páginas: 2 (456 palabras) Publicado: 24 de julio de 2015
ARREGLO UNIDIMENSIONAL
1. Elabore un programa que permita aceptar 5 números enteros en un vector, seguidamente se deben mostrar estos números ingresados.


// DECLARACION DE VARIABLES
intN, c;
int NUM[]; // SE DECLARA EL ARREGLO
NUM = new int[5]; // SE CREA EL ARREGLO
// INGRESO DE DATOS, SE CAPTURAN COMO String (TEXTO)
for ( int I = 0; I <=4; I++)
{
c=I+1;
String sN=JOptionPane.showInputDialog("Ingrese " + c +"°"+ " Numero Entero:");
// CONVERTIR LOS DATOS INGRESADOS A NUMEROSN=Integer.parseInt(sN);
NUM[I]=N;
}

System.out.println(" Los Numeros Ingresados son: ");
for ( int I = 0; I <= 4; I++)
{
System.out.println(NUM[I]+" ");
}

2. Elabore un programa que permita aceptar 5 números enteros en un vector, seguidamente se deben mostrar estos números ingresados ordenados en forma ascendente.

// DECLARACIONDE VARIABLES
int N, c, AUX;
int NUM[]; // SE DECLARA EL ARREGLO
NUM = new int[5]; // SE CREA EL ARREGLO
// INGRESO DE DATOS, SE CAPTURAN COMO String (TEXTO)for ( int I = 0; I <= 4; I++)
{
c=I+1;
String sN=JOptionPane.showInputDialog("Ingrese " + c +"°"+ " Numero Entero:");
// CONVERTIR LOS DATOS INGRESADOSA NUMEROS
N=Integer.parseInt(sN);
NUM[I]=N;
}
// haciendo uso del metodo de la burbuja
for ( int I=0; I<=3;I++)
for ( int J=I + 1;J<=4;J++)
if (NUM[J] < NUM[I])
{
AUX = NUM[I];
NUM[I]= NUM[J];NUM[J]= AUX;
}

System.out.println(" Los Numeros Ingresados y ordenados en forma ascendente son: ");
for ( int I...
Leer documento completo

Regístrate para leer el documento completo.

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS