Commit 0a4d3a17 authored by daniel.parker's avatar daniel.parker

final.

parent 4b4a9ef2
...@@ -64,18 +64,8 @@ public class Program { ...@@ -64,18 +64,8 @@ public class Program {
public static void main(String[] args) { public static void main(String[] args) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
ConvertBinaryToInt(binaryInput);
String[] input = {"010","110","111","1010101"};
String[] input2 = {"50","110","FA","B0","F"};
int[] set = {3,6,7,9,8,7,7,6,5,15};
System.out.println(Median(set));
System.out.println(ConvertSingb3ToInt("12"));
System.out.println(ConvertSingb20ToInt("50"));
System.out.println(ConvertSingleHexToInt("50"));
System.out.println(ConvertSingleBinaryToInt("101"));
System.out.println(Arrays.toString(ConvertBinaryToInt(input)));
} }
...@@ -178,15 +168,31 @@ System.out.println(Median(set)); ...@@ -178,15 +168,31 @@ System.out.println(Median(set));
public static int[] Union(int[] intArrayA, int[] intArrayB) { public static int[] Union(int[] intArrayA, int[] intArrayB) {
ArrayList<Integer> unionList = new ArrayList<Integer>(); ArrayList<Integer> unionList = new ArrayList<Integer>();
for(int i = 0; i<intArrayA.length;i++) {
unionList.add(intArrayA[i]);
}
for(int i = 0; i<intArrayB.length;i++) {
unionList.add(intArrayB[i]);
}
unionList.sort(null);
for(int i = 0; i < unionList.size();i++) {
for(int j = 0; j < unionList.size();j++) {
if(i==j)
continue;
if(unionList.get(j).equals(unionList.get(i)))
unionList.remove(j);
}
}
int[] resultsArray = new int[unionList.size()]; int[] resultsArray = new int[unionList.size()];
for(int i = 0; i<unionList.size(); i++) { for(int i = 0; i<unionList.size(); i++) {
resultsArray[i] = unionList.get(i); resultsArray[i] = unionList.get(i);
System.out.println(resultsArray);
} }
return resultsArray; return resultsArray;
...@@ -213,18 +219,29 @@ System.out.println(Median(set)); ...@@ -213,18 +219,29 @@ System.out.println(Median(set));
public static int[] Difference(int[] intArrayA, int[] intArrayB) { public static int[] Difference(int[] intArrayA, int[] intArrayB) {
int counter = 0;
ArrayList<Integer> differenceList = new ArrayList<Integer>(); ArrayList<Integer> differenceList = new ArrayList<Integer>();
for(int i = 0; i<intArrayA.length;i++) {
counter = 0;
for(int j = 0; j<intArrayB.length; j++) {
if(intArrayA[i]==intArrayB[j]) {
counter++;
}
}
if(counter==0) {
differenceList.add(intArrayA[i]);
}
}
int[] resultsArray = new int[differenceList.size()]; int[] resultsArray = new int[differenceList.size()];
for(int i = 0; i<differenceList.size(); i++) { for(int i = 0; i<differenceList.size(); i++) {
resultsArray[i] = differenceList.get(i); resultsArray[i] = differenceList.get(i);
} }
System.out.println(resultsArray);
return resultsArray; return resultsArray;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment