瀏覽代碼

SquareArrayAnalyzer

Nathan Hall 6 年之前
父節點
當前提交
40712fa557
共有 1 個檔案被更改,包括 8 行新增7 行删除
  1. 8
    7
      src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java

+ 8
- 7
src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java 查看文件

@@ -1,19 +1,20 @@
1 1
 package rocks.zipcode.io.quiz3.arrays;
2 2
 
3
+import java.util.Arrays;
4
+
3 5
 /**
4 6
  * @author leon on 09/12/2018.
5 7
  */
6 8
 public class SquareArrayAnalyzer {
7 9
     public static Boolean compare(Integer[] input, Integer[] squaredValues) {
10
+        Arrays.sort(input);
11
+        Arrays.sort(squaredValues);
8 12
 
9 13
 
10
-        for (int i = 0; i <= input.length; i++) {
11
-            System.out.println(input[i] * input[i]);
12
-//            System.out.println(squaredValues[i]);
13
-
14
-//            if (squaredValues[i] != (input[i] * input[i])){
15
-//                return false;
16
-//            }
14
+        for (int i = 0; i < input.length; i++) {
15
+            if (squaredValues[i] != (input[i] * input[i])){
16
+                return false;
17
+            }
17 18
         }
18 19
         return true;
19 20
     }