sábado, 25 de febrero de 2023

Orden

 

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 = false, decreciente = false;

System.out.println("Llenar el arreglo");

for (int i = 0; i < 10; i++) {

System.out.print((i + 1) + ". Digite un numero: ");

arreglo[i] = entrada.nextInt();

}

for (int i = 0; i < 9; i++) {

if (arreglo[i] < arreglo[i + 1]) {

creciente = true;

}

if (arreglo[i] > arreglo[i + 1]) {

decreciente = true;

}

}

if (creciente == true && decreciente == false) {

System.out.println("CRECIENTE");

} else if (creciente == false && decreciente == true) {

System.out.println("DECRECIENTE");

} else if (creciente == true && decreciente == true) {

System.out.println("DESORDENADA");

} else if (creciente == false && decreciente == false) {

System.out.println("TODOS SON IGUALES");

}

}

No hay comentarios:

Publicar un comentario