Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package numerosordemcrescente;
- /**
- *
- * @author Vini
- */
- public class Main {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int numerosOrdemCrescente = 0;
- for (int i = 1000; i <= 9999; i++) {
- int primeiroDigito = i/1000;
- int segundoDigito = (i%1000)/100;
- int terceiroDigito = (i%100)/10;
- int quartoDigito = i%10;
- if (primeiroDigito < segundoDigito && segundoDigito < terceiroDigito && terceiroDigito < quartoDigito) {
- System.out.println(i);
- numerosOrdemCrescente += 1;
- }
- }
- System.out.println("\nNúmeros em ordem crescente entre 1000 e 9999: " + numerosOrdemCrescente);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement