int a =Integer.parseInt(JOptionPane.showInputDialog
(null,"请输入一个数:"));
int e = a;
int c = 0;
// 求出这个数的二进制长度
while(a!=0){
a =a/2;
c++;
}
// 将二进制码变为数组并反向赋值
int [] d = new int[c];
int j = c-1;
while(e!=0){
d[j] =e%2;
e =e/2;
j--;
}
for (int i = 0; i < d.length; i++) {
System.out.print(d[i]);
}
}