Thursday, January 29, 2015

Binary.java in program



Binary.java

public class Binary
             { 
public static void main(String[] args) 
{ 
        int n = Integer.parseInt(args[0]);
                     int v = 1;
        while (v <= n/2) 
        v = v * 2;
        }
         while (v > 0) 
         {
                       if (n < v) 
         {
          System.out.println(0);
            }
                       else 
              {
                System.out.println(1);
                n = n - v;
            }
                        v = v / 2;
        }
                      System.out.println();
                      }
                    }

No comments:

Post a Comment