Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class Binario3 {
  2. public static void main (String args[]) {
  3. int numero= 156;
  4. int Resultado []= new int [32];
  5. int i= 0;
  6.  
  7. while (numero > 0) {
  8. Resultado[i] = (numero%2);
  9. i++;
  10. numero= numero/2;
  11. }
  12. int j= Resultado.length - 1 ;
  13.  
  14. while (Resultado[j] == 0) {
  15. j--;
  16. }
  17. for (; j>=0 ; j--) {
  18. System.out.print ( Resultado[j] );
  19. }
  20. System.out.println (" " );
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement