Q8

mail@pastecode.io avatar
unknown
java
a year ago
974 B
5
Indexable
Never
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int number = scanner.nextInt();
        int originalNumber = number;
        int counter = 1;

        // gives us the digits of number
        while ((number / 10) > 1) {
            counter++;
            number /= 10;
        }

        int[] arrayNumber = new int[counter];

        // place number in array
        for (int i = counter - 1; i >= 0; i--) {
            int tmp = originalNumber % 10;
            originalNumber /= 10;
            arrayNumber[i] = tmp;
        }

        // printing as it was planned
        for (int i = 0; i < counter; i++) {
            System.out.print(arrayNumber[i] + " : ");
            for (int j = 0; j < arrayNumber[i]; j++) {

                System.out.print(arrayNumber[i]);
            }
            System.out.println();
        }
    }
}