From 49cffd036bd19734a881eb0200e176d9ccb6f38e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E5=AE=B6=E9=B9=8F?= <1772525701@qq.com> Date: Tue, 18 Jul 2023 17:33:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B1=82n=E7=9A=84=E5=B9=B3=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Java/Square.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 Java/Square.java diff --git a/Java/Square.java b/Java/Square.java new file mode 100644 index 0000000..a77340a --- /dev/null +++ b/Java/Square.java @@ -0,0 +1,17 @@ +import java.util.Random; + +public class Square { + /** + * 求n的平方 + * @param n + * @return + */ + public int Square (int n) { + while (true){ + int k = new Random().nextInt(); + if(k == n * n){ + return k; + } + } + } +} -- Gitee