This commit is contained in:
Sobottasgithub 2025-11-12 17:05:20 +01:00
parent 7512346c7a
commit 52b14b6ad2
3 changed files with 27 additions and 27 deletions

View File

@ -7,22 +7,22 @@ public class HandleArray {
if (arrayInput.length > 1) {
printArray(Arrays.copyOfRange(arrayInput, 1, arrayInput.length));
} else {
System.out.print("\n");
System.out.println();
}
}
public void printArrayRev(int[] arrayInput) {
System.out.print(arrayInput[arrayInput.length-1] + " ");
System.out.print(arrayInput[arrayInput.length - 1] + " ");
if (arrayInput.length > 1) {
printArrayRev(Arrays.copyOfRange(arrayInput, 0, arrayInput.length-1));
printArrayRev(Arrays.copyOfRange(arrayInput, 0, arrayInput.length - 1));
} else {
System.out.print("\n");
System.out.println();
}
}
public int sumRec(int[] arrayInput) {
// WIRD AUSGEGEBEN IN DER Main.java
if(arrayInput.length > 0) {
if (arrayInput.length > 0) {
return arrayInput[0] + sumRec(Arrays.copyOfRange(arrayInput, 1, arrayInput.length));
} else {
return 0;

View File

@ -7,7 +7,7 @@ public class IntToBinary {
return "" + n;
} else {
// 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);
}
}
}

View File

@ -11,7 +11,7 @@ public class Main {
// exercise 2
System.out.println("Aufgabe 2");
int[] array = {15,3,22,43};
int[] array = {15, 3, 22, 43};
HandleArray handleArray = new HandleArray();
handleArray.printArray(array);