public class PJJJeden { public static void main(String[] args) { int number = 12354; int c = Count(number); int[] digits = new int[c]; for (int i = c - 1; i >= 0; i--) { digits[i] = number % 10; number = number / 10; } for (int number : digits) { System.out.println(number); } } public static int Count(int number) { int count = 0; while (number != 0) { number = number / 10; count++; } return count; } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter