From f647a2f12dafc056034263b0bb0979ede163da26 Mon Sep 17 00:00:00 2001 From: algorithmzuo Date: Thu, 23 Dec 2021 14:46:28 +0800 Subject: [PATCH] modify code --- src/class02/Code03_KM.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/class02/Code03_KM.java b/src/class02/Code03_KM.java index abd03b4..3f037aa 100644 --- a/src/class02/Code03_KM.java +++ b/src/class02/Code03_KM.java @@ -110,7 +110,7 @@ public class Code03_KM { // [-range, +range] public static int randomNumber(int range) { - return ((int) (Math.random() * range) + 1) - ((int) (Math.random() * range) + 1); + return (int) (Math.random() * (range + 1)) - (int) (Math.random() * (range + 1)); } public static void main(String[] args) {