You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
firstwork/jinzhi.java

13 lines
326 B

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