Add Arrays
This commit is contained in:
41
arrays.md
41
arrays.md
@ -5,3 +5,44 @@ url: https://git.haw-hamburg.de/pm1-tutorium/slides
|
|||||||
header: Programmieren 1 **Tutorium**
|
header: Programmieren 1 **Tutorium**
|
||||||
footer: Henri Burau und Eva Meinen
|
footer: Henri Burau und Eva Meinen
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
# Arrays
|
||||||
|
|
||||||
|
```java
|
||||||
|
int[] array1 = new int[5];
|
||||||
|
|
||||||
|
int[] array2 = {1, 2, 3, 4, 5};
|
||||||
|
```
|
||||||
|
|
||||||
|
Array-Elemente werden über Index angesprochen, beginnend bei 0;
|
||||||
|
|
||||||
|
```java
|
||||||
|
for(int i = 0; i < array1.length ; i++){
|
||||||
|
array1[i] = i;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
##
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
## Mehrdimensionale Arrays
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
|
||||||
|
* m[0][0][0]
|
||||||
|
* m[1][2][5]
|
||||||
|
* m[1][3]
|
||||||
|
|
||||||
|
|
||||||
|
##Aufgaben
|
||||||
|
|
||||||
|
1) Schreibe eine Methode int produkt(int[] values), die das Produkt (Ergebnis einer Multiplikation) zurück gibt
|
||||||
|
|
||||||
|
2) Schreibe eine Methode sort5(int[] values), welche zuerst alle Werte auf die größer 5 und dann alle Werte < 5 auf der Konsole ausgeben.
|
||||||
|
|
||||||
|
3) Aufgabe Sieb des Eratosthenes aus der VL (wer dies noch nicht bearbeitet hat)
|
||||||
|
|
||||||
|
4) Tik-Tak-Toe-Spiel implementieren
|
||||||
3
img/array.svg
Normal file
3
img/array.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 5.5 KiB |
BIN
img/arrays2.PNG
Normal file
BIN
img/arrays2.PNG
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
Reference in New Issue
Block a user