Add Arrays

This commit is contained in:
acp059 2020-03-31 19:13:58 +02:00
parent 8582fec553
commit 51b830bbed
3 changed files with 44 additions and 0 deletions

View File

@ -5,3 +5,44 @@ url: https://git.haw-hamburg.de/pm1-tutorium/slides
header: Programmieren 1 **Tutorium**
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;
}
```
##
![bg right:100% 100%](https://git.haw-hamburg.de/pm1-tutorium/slides/-/raw/master/img/array.svg)
## Mehrdimensionale Arrays
![bg right:40% 100%](https://git.haw-hamburg.de/pm1-tutorium/slides/-/raw/master/img/arrays2.png)
* 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

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
img/arrays2.PNG Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB