View Code of Problem 54

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long num = sc.nextLong();
        int[] res = new int[20];
        int i = 0;
        while(num != 0) {
            res[i] = (int)num % 10;
            i++;
            num /= 10;
        }

        for(i = i - 1; i >= 0; i--) {
            System.out.print(res[i]);
            if(i > 0) {
                System.out.print(" ");
            }
        }
    }
}

Double click to view unformatted code.


Back to problem 54