main
guixu0320 1 month ago
parent a24c1f925d
commit 9a4d7b249e

@ -1,13 +1,13 @@
public class jinzhi {
public static void main(String[] args) {
int a = 15;
int n = 0;
int x = 0;
int i=0;
while (a > 0) {
n = (int) (n + (a % 2) * Math.pow(10,i));
x = (int) (x + (a % 2) * Math.pow(10,i));
a = a / 2;
i=i+1;
}
System.out.print("jinzhi十进制a转换二进制n为" + n);
System.out.print("jinzhi11111十进制a转换二进制x为" + x);
}
}
Loading…
Cancel
Save