Advertisement
Guill

ddds

Aug 14th, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. package javaapplication3;
  2. public class JavaApplication3 {
  3. public static void main(String[] args) {
  4. dectobin(args,2036);
  5. // bintodec(args,"1111100");
  6. }
  7. public static void JavaApplication3() {
  8.  
  9. }
  10.  
  11.  
  12.  
  13. static void dectobin(String[] args, Integer a){
  14. int[] tab = new int[255];
  15. int i = 0;
  16. while(Math.pow(2,i) <= a){
  17. tab[i] = (int) Math.pow(2,i);
  18. p(tab[i]);
  19. i = i + 1;
  20. }
  21. String r = "";
  22. while(i > 0){
  23. i = i - 1;
  24. if(a >= tab[i]){
  25. r = r + "1";
  26. a = a - tab[i];
  27. }
  28. else
  29. {
  30. r = r + "0";
  31. }
  32. }
  33. p("\n" + r);
  34. }
  35.  
  36. public String descrição = "glaglag";
  37.  
  38.  
  39. static void bintodec(String[] args, String a){
  40. int[] tab = new int[255];
  41. int i = a.length() - 1;
  42. while(i >= 0){
  43. tab[i] = (int) Math.pow(2,i);
  44. p(tab[i]);
  45. i = i - 1;
  46. }
  47. i = a.length() - 1;
  48. while(i >= 0){
  49.  
  50. }
  51.  
  52.  
  53.  
  54. /*
  55. String r = "";
  56. while(i > 0){
  57. i = i - 1;
  58. if(a >= tab[i]){
  59. r = r + "1";
  60. a = a - tab[i];
  61. }
  62. else
  63. {
  64. r = r + "0";
  65. }
  66. }
  67. p("\n" + r); */
  68. }
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75. static void p(Object stri){
  76. System.out.print(stri);
  77. }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement