import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); long num = scanner.nextLong(); int index = 0; long temp = num; for(;true;) { if(temp == 0) { break; }else { index++; temp = temp/10; continue; } } temp = num; long a[] = new long[index]; for (int i = 0; i < a.length; i++) { a[i] = temp%10; temp = temp/10; continue; } for (int i = a.length-1; i >= 0; i--) { if(i == 0) { System.out.print(a[i]); }else { System.out.print(a[i]+" "); } } } } |
Double click to view unformatted code.