SHARE
TWEET

decimal integer to array

DulcetAirman Dec 12th, 2016 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.   public static void main(final String[] args) {
  3.     try (Scanner scan = new Scanner(System.in)) {
  4.       int n=scan.nextInt();
  5.       final int[] a = new int[(int) Math.floor(Math.log10(n) + 1)];
  6.       int rem;
  7.       int i=0;
  8.       while(n!=0)
  9.       {
  10.         rem=(n%10);
  11.         a[a.length - i - 1] = rem;
  12.         n = n/10;
  13.         i++;
  14.       }
  15.       System.out.println(Arrays.toString(a));
  16.     }
  17.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top