Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OrdemCrescente {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int num;
- System.out.println("Entre com a quantidade de números para ser ordenado em ordem crescente: ");
- num = sc.nextInt();
- int [] valores = new int [num];
- for(int i = 0; i < num; i++){
- System.out.println("Entre com os números para ser ordenado em ordem crescente: ");
- valores[i] = sc.nextInt();
- }
- int aux;
- for(int i = 0; i < num-1; i++){
- if(valores[i] < valores[i+1]){
- aux = valores[i];
- valores[i] = valores[i+1];
- valores[i+1] = aux;
- i = -1;
- }
- }
- for(int i = 0; i < num; i++){
- System.out.println(valores[i]);
- }
- }
- }
Add Comment
Please, Sign In to add comment