package operadores;
import java.util.Scanner;
public class persona {
public static void main(String[] args) {
Scanner entrada = new Scanner(System.in);
int arreglo[] = new int[10];
boolean creciente = true;
int numero, sitio_num = 0, j = 0;
System.out.println("Llenar el arreglo");
do {
for (int i = 0; i < 5; i++) {
System.out.print((i + 1) + ". Digite un numero: ");
arreglo[i] = entrada.nextInt();
}
for (int i = 0; i < 4; i++) {
if (arreglo[i] < arreglo[i + 1]) {
creciente = true;
}
if (arreglo[i] > arreglo[i + 1]) {
creciente = false;
break;
}
}
if (creciente == false) {
System.out.println("NO ESTA CRECIENTE");
}
} while (creciente == false);
System.out.print("Digite un numero: ");
numero = entrada.nextInt();
while (arreglo[j] < numero && j < 5) {
sitio_num++;
j++;
}
for (int i = 4; i >= sitio_num; i--) {
arreglo[i + 1] = arreglo[i];
}
arreglo[sitio_num] = numero;
System.out.print("Queda: ");
for (int i = 0; i < 6; i++) {
System.out.print(arreglo[i] + " - ");
}
}
}
No hay comentarios:
Publicar un comentario