I create an array that then prints in sets of five. I want to then be able to search the array by 5 to see if there are any duplicates. I've tried but I can only think of a way to search by each value not five. If anyone can point me in the right direction, that would be great. Thanks.
public class findPat {
static int arr [] = new int [10];
static int st = 1;
static int end = 56;
static double t1;
static double t2;
public static void main(String[] args){
t1=System.currentTimeMillis();
for(int n=0; n<100; n++){
for (int i=0; i<arr.length; i++)
arr[i]= (int) (Math.random()* (end-st +1)) +st;
for (int i=0; i<5; i++){
if (i%5==0)
System.out.println();
System.out.print("\t" + arr[i]);}
}
t2=System.currentTimeMillis();
System.out.println();
System.out.println();
System.out.println("\t" + "Total run time is " + ((t2-t1)) + "ms");
}
}
the console looks like this:
18 22 42 14 38
2 2 14 9 8
6 29 38 37 33
6 41 41 27 7
20 41 38 11 50
16 17 41 21 19
40 33 9 10 7
12 54 10 30 36
however each row is in the same array but is just printing 5 at a time. the console will have more than just those few lines. I want to be able to search the array and check each row against the rest to see how many times it appears, if it does.