elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recopilación Tutoriales y Manuales Hacking, Seguridad, Privacidad, Hardware, etc


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / Re: Separar numeros en digitos individuales en: 13 Noviembre 2018, 21:48 pm
en java:

 public static void main(String[] args) {
       
        Scanner teclado=new Scanner(System.in);
        int num=0;
        int aumento=10;
        int div=1;
        int numeros[]=null;
        do {           
         System.out.println("Ingresa un numero: (numero mayor que cero y menor de 7 digitos)");
         num=teclado.nextInt();         
        } while (num<1 || num>999999);
       
        String num2=String.valueOf(num);
        numeros=new int[num2.length()];
        for (int i = 0; i < num2.length() ; i++) {
           
            numeros=num%aumento/div;
            aumento=aumento*10;
            div=div*10;
        }
       for (int i = numeros.length-1; i >=0; i--) {           
        System.out.println(""+numeros);
        }
    }
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines