From 45d68a6b2ede4df8a14dc6c0c215bb4401995642 Mon Sep 17 00:00:00 2001 From: fdzcxy212206296 <3488249364@qq.com> Date: Thu, 10 Oct 2024 15:14:58 +0800 Subject: [PATCH] ADD file via upload --- jinzhi.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 jinzhi.java diff --git a/jinzhi.java b/jinzhi.java new file mode 100644 index 0000000..94270ea --- /dev/null +++ b/jinzhi.java @@ -0,0 +1,13 @@ +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); + } +} \ No newline at end of file