Sequence of individual digits

 Sequence of individual digits

Problem Description


Write a Java program to break an integer into a sequence of individual digits.

Logic Test Case 1


Input (stdin)

123456


Expected Output


1 2 3 4 5 6

Logic Test Case 2


Input (stdin)

543242


Expected Output


5 4 3 2 4 2



Code Area

import java.io.*;

import java.util.*;

public class TestClass {


    public static void main(String[] args)

    {

        Scanner in = new Scanner(System.in);

        System.out.print("");

        int input = in.nextInt();

        int n1 = input / 100000 % 10;

        int n2 = input / 10000 % 10;

        int n3 = input / 1000 % 10;

        int n4 = input / 100 % 10;

        int n5 = input / 10 % 10;

        int n6 = input % 10;

      System.out.print(n1 + " " + n2 + " " + n3 + " " + n4 + " " + n5 + " " + n6);


    }

}


Post a comment

0 Comments