Fixup
This commit is contained in:
parent
7512346c7a
commit
52b14b6ad2
@ -7,22 +7,22 @@ public class HandleArray {
|
|||||||
if (arrayInput.length > 1) {
|
if (arrayInput.length > 1) {
|
||||||
printArray(Arrays.copyOfRange(arrayInput, 1, arrayInput.length));
|
printArray(Arrays.copyOfRange(arrayInput, 1, arrayInput.length));
|
||||||
} else {
|
} else {
|
||||||
System.out.print("\n");
|
System.out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printArrayRev(int[] arrayInput) {
|
public void printArrayRev(int[] arrayInput) {
|
||||||
System.out.print(arrayInput[arrayInput.length-1] + " ");
|
System.out.print(arrayInput[arrayInput.length - 1] + " ");
|
||||||
if (arrayInput.length > 1) {
|
if (arrayInput.length > 1) {
|
||||||
printArrayRev(Arrays.copyOfRange(arrayInput, 0, arrayInput.length-1));
|
printArrayRev(Arrays.copyOfRange(arrayInput, 0, arrayInput.length - 1));
|
||||||
} else {
|
} else {
|
||||||
System.out.print("\n");
|
System.out.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int sumRec(int[] arrayInput) {
|
public int sumRec(int[] arrayInput) {
|
||||||
// WIRD AUSGEGEBEN IN DER Main.java
|
// WIRD AUSGEGEBEN IN DER Main.java
|
||||||
if(arrayInput.length > 0) {
|
if (arrayInput.length > 0) {
|
||||||
return arrayInput[0] + sumRec(Arrays.copyOfRange(arrayInput, 1, arrayInput.length));
|
return arrayInput[0] + sumRec(Arrays.copyOfRange(arrayInput, 1, arrayInput.length));
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -7,7 +7,7 @@ public class IntToBinary {
|
|||||||
return "" + n;
|
return "" + n;
|
||||||
} else {
|
} else {
|
||||||
// Prevent adding the numbers by converting to String and convert it back to int after
|
// Prevent adding the numbers by converting to String and convert it back to int after
|
||||||
return binary(n/2) + (n%2);
|
return binary(n / 2) + (n % 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,7 +11,7 @@ public class Main {
|
|||||||
|
|
||||||
// exercise 2
|
// exercise 2
|
||||||
System.out.println("Aufgabe 2");
|
System.out.println("Aufgabe 2");
|
||||||
int[] array = {15,3,22,43};
|
int[] array = {15, 3, 22, 43};
|
||||||
HandleArray handleArray = new HandleArray();
|
HandleArray handleArray = new HandleArray();
|
||||||
|
|
||||||
handleArray.printArray(array);
|
handleArray.printArray(array);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user