Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class aufgabe2 {
- static int n = IO.readInt("Bitte n Kinder eingeben: ");
- static int m = IO.readInt("Bitte m Runden eingeben: ");
- public static void main(String[] args) {
- int [] array = new int [n];
- int [] fuelleArray = fuelleArray(array);
- int [] ergebnis = zaehleAb(fuelleArray);
- print(ergebnis);
- }
- static int [] zaehleAb(int[] array) {
- int [] erg = new int [n];
- for (int aktI = 0; aktI <array.length; aktI++) {
- if (array[m-1]!=0) {
- erg [aktI] = array[m-1];
- array[m-1] = 0;
- }
- }
- return erg;
- }
- static int[] fuelleArray(int[] array) {
- int sum = 1;
- int[]newArray = new int [n];
- for (int i = 0; i < newArray.length; i++) {
- newArray[i] = sum;
- sum++;
- }
- return newArray;
- }
- static void print(int[] matrix) {
- IO.print("Ergebnis: ");
- for (int r = 0; r < matrix.length; r++) {
- System.out.print(matrix[r] + " ");
- }
- System.out.println();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement