-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathTestsMPAT.java
More file actions
58 lines (55 loc) · 1.55 KB
/
Copy pathTestsMPAT.java
File metadata and controls
58 lines (55 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Random;
import java.util.Arrays;
/**
* Write a description of class TestsMPAT here.
*
* @author Amal Thomas, Michael Plekan
* @version Spring 2021
*/
public class TestsMPAT
{
/**
* @param input args[0] The amout of values in the arrays
*/
public static void main(String[] args){
Random rand=new Random();
int input=0;
try
{
input=Integer.parseInt(args[0]);
}
catch (Exception e)
{
System.out.println("Error. Must enter long as command line parameter.");
System.exit(-1);
}
int[] list1=new int[input];
long[] list2=new long[input];
TopKJDTRefSol top = new TopKJDTRefSol(5, Comparator.naturalOrder());
for(int x =0;x<input;x++){
list1[x]=rand.nextInt();
list2[x]=rand.nextLong();
}
for(int i:list1){
top.add(i);
}
Arrays.sort(list1);
System.out.println("this is the last 5 of the list after being sorted");
for(int x =input-5;x<input;x++){
System.out.println(list1[x]);
}
System.out.println(top);
top.clear();
for(long i:list2){
top.add(i);
}
Arrays.sort(list2);
System.out.println("this is the last 5 of the list after being sorted");
for(int x =input-5;x<input;x++){
System.out.println(list2[x]);
}
System.out.println(top);
}
}