Kaynağa Gözat

SquareArrayAnalyzer

Nathan Hall 6 yıl önce
ebeveyn
işleme
40712fa557

+ 8
- 7
src/main/java/rocks/zipcode/io/quiz3/arrays/SquareArrayAnalyzer.java Dosyayı Görüntüle

1
 package rocks.zipcode.io.quiz3.arrays;
1
 package rocks.zipcode.io.quiz3.arrays;
2
 
2
 
3
+import java.util.Arrays;
4
+
3
 /**
5
 /**
4
  * @author leon on 09/12/2018.
6
  * @author leon on 09/12/2018.
5
  */
7
  */
6
 public class SquareArrayAnalyzer {
8
 public class SquareArrayAnalyzer {
7
     public static Boolean compare(Integer[] input, Integer[] squaredValues) {
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
         return true;
19
         return true;
19
     }
20
     }