Skip to content

Instantly share code, notes, and snippets.

@JuanjoSalvador
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JuanjoSalvador/a26f00fcc656dc911d72 to your computer and use it in GitHub Desktop.
Save JuanjoSalvador/a26f00fcc656dc911d72 to your computer and use it in GitHub Desktop.
// Programa para separar los digitos de un número dado
import java.util.Scanner;
public class Separador {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int numero, d1, d2, d3, d4, d5;
System.out.println("Ingrese un número de 5 dígitos: ");
numero = input.nextInt();
d1 = numero % 10;
d2 = numero % 100 / 10;
d3 = numero % 1000 / 100;
d4 = numero % 10000 / 1000;
d5 = numero % 100000 / 10000;
System.out.println("El número ingresado está compuesto por los siguiente dígitos: ");
System.out.printf("%d %d %d %d %d\n\n", d5, d4, d3, d2, d1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment