Untitled

From Cream Marmoset, 1 Month ago, written in Plain Text, viewed 32 times.
URL http://codebin.org/view/323bfbb7 Embed
Download Paste or View Raw
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class Solution {
  5.  
  6.     public static void main(String[] args) {
  7.         /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
  8.         int tc,n;
  9.         Scanner sc= new Scanner(System.in);
  10.         tc=sc.nextInt();
  11.         for(int i=0;i<tc;i++)
  12.         {
  13.             n=sc.nextInt();
  14.             int j=0;
  15.             char bin[]= new char[31];
  16.             while(n>1)
  17.             {
  18.                 int rem = n%2;
  19.                 bin[j]=(char)rem;
  20.                 n/=2;
  21.                 j++;
  22.             }
  23.             for(int x=j;x>=0;x--)
  24.             {
  25.                 System.out.print(bin[x]);
  26.             }
  27. }
  28. }
  29. }

Reply to "Untitled"

Here you can reply to the paste above