Sfoglia il codice sorgente

SquareArrayAnalyzer

Nathan Hall 6 anni fa
parent
commit
40712fa557

+ 8
- 7
src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java Vedi File

@@ -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
     }