Skip to content

Commit

Permalink
Revise L02 L03
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianZug committed Nov 18, 2024
1 parent 31fe343 commit f089b24
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 14 deletions.
24 changes: 21 additions & 3 deletions 02_OperatorenKontrollstrukturen.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ logo: ./img/LogoCodeExample.png
import: https://github.com/liascript/CodeRunner
https://github.com/LiaTemplates/AVR8js/main/README.md#10
https://raw.githubusercontent.com/TUBAF-IfI-LiaScript/VL_EAVD/master/config.md
https://raw.githubusercontent.com/liaScript/mermaid_template/master/README.md
-->

Expand Down Expand Up @@ -804,12 +805,22 @@ Schleifen können verschachtelt werden, d.h. innerhalb eines Schleifenkörpers
können weitere Schleifen erzeugt und ausgeführt werden. Zur Beschleunigung des
Programmablaufs werden Schleifen oft durch den Compiler entrollt (*Enrollment*).

{{0-1}}
*************************************************

Grafisch lassen sich die wichtigsten Formen in mit der Nassi-Shneiderman
Diagrammen wie folgt darstellen:

* Iterationssymbol

![Modelle](https://www.plantuml.com/plantuml/png/SoWkIImgAStDuG8pk3BJ53IIy_DICaioy_CK73KLIZ9IynGqAbEBDRaK5An2KYjA50ojkL9pYbDHbJfXLMfa3MGMb-GNOD7XZ5M7CJR3NR0gDO4eLT38oo_9oCnBHyY0X86IGErfN63R7O1ia2S1 "Darstellungsbeispiele für mehrstufige Verzweigungen (`switch`)")<!-- width="60%" -->
```mermaid @mermaid
graph TD
Start --> Überprüfung{Bedingung A erfüllt?}
Überprüfung -->|Ja| Aktion1[Aktion 1]
Aktion1 --> Überprüfung2{Bedingung B erfüllt?}
Überprüfung2 -->|Ja| Aktion2[Aktion 2]
Aktion2 --> Überprüfung
Überprüfung2 -->|Nein| Überprüfung
Überprüfung -->|Nein| Ende
```


<!--
Expand All @@ -825,6 +836,11 @@ style="width: 80%; min-width: 420px; max-width: 720px;"
+-+-------------------------------------------------------------------+ .
```

*************************************************

{{1-2}}
*************************************************

* Wiederholungsstruktur mit vorausgehender Bedingungsprüfung

<!--
Expand Down Expand Up @@ -858,6 +874,8 @@ style="width: 80%; min-width: 420px; max-width: 720px;"
Die Programmiersprache C/C++ kennt diese drei Formen über die Schleifenkonstrukte
`for`, `while` und `do while`.

*************************************************

#### `for`-Schleife

Der Parametersatz der `for`-Schleife besteht aus zwei Anweisungsblöcken und einer
Expand Down
26 changes: 15 additions & 11 deletions 03_ArrayZeigerReferenzen.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Datentyp Variablenname[Anzahl_der_Elemente];
int a[6];
```


<!-- data-type="none" style="table-layout: fixed; max-width:600px;"-->
| `a[0]` | `a[1]` | `a[2]` | `a[3]` | `a[4]` | `a[5]` |


Expand All @@ -94,7 +96,7 @@ Datentyp Variablenname[Anzahl_der_Elemente_Dim0][Anzahl_der_Elemente_Dim1];
```cpp
int a[3][5];
```

<!-- data-type="none" style="table-layout: fixed; max-width:800px;"-->
| | Spalten | | | | |
| ---------- | --------- | --------- | --------- | --------- | --------- |
| **Zeilen** | `a[0][0]` | `a[0][1]` | `a[0][2]` | `a[0][3]` | `a[0][4]` |
Expand Down Expand Up @@ -339,7 +341,7 @@ int main(void) {
cout<<"->"<<b<<"<-\n";
char c[] = "Noch eine \0Moeglichkeit";
cout<<"->"<<c<<"<-\n";
char d[] = { 80, 114, 111, 122, 80, 114, 111, 103, 32, 50, 48, 50, 50, 0 };
char d[] = { 69, 65, 86, 68, 32, 50, 48, 50, 52, 0 };
cout<<"->"<<d<<"<-\n";
return 0;
}
Expand Down Expand Up @@ -425,7 +427,7 @@ Programmiertechniken lassen sich realisieren:
* Übergabe von Funktionen als Argumente an andere Funktionen,
* Umsetzung rekursiver Datenstrukturen wie Listen und Bäume.

> An dieser Stelle sei erwähnt, dass die Übergabe der "call-by-reference"-Parameter via Reference ist ebenfalls möglich und einfacher in der Handhabung.
> An dieser Stelle sei bereits erwähnt, dass die Übergabe der "call-by-reference"-Parameter via Reference ist ebenfalls möglich und einfacher in der Handhabung.
### Definition von Zeigern

Expand All @@ -447,7 +449,6 @@ int *zeiger4, *zeiger5;
int *zeiger6, ganzzahl;
```


### Initialisierung

> **Merke:** Zeiger müssen vor der Verwendung initialisiert werden.
Expand Down Expand Up @@ -482,7 +483,7 @@ int main(void)
return 0;
}
```
@LIA.eval(`["main.cpp"]`, `g++ -Wall main.cpp -o a.out`, `./a.out`)
@LIA.evalWithDebug(`["main.cpp"]`, `g++ -Wall main.cpp -o a.out`, `./a.out`)
{{1}}
Expand Down Expand Up @@ -571,7 +572,7 @@ int main(void)
{
int a = 5;
int * ptr_a = &a;
cout<<"Pointer ptr_a "<<(void*)ptr_a<<"\n";
cout<<"Pointer ptr_a "<<ptr_a<<"\n";
cout<<"Wert hinter dem Pointer ptr_a "<<ptr_a<<"\n";
cout<<"Aus Maus!\n";
return 0;
Expand All @@ -590,9 +591,12 @@ using namespace std;
int main(void)
{
int * ptr_a;
*ptr_a = 10;
// korrekte Initalisierung
// int * ptr_a = NULL;
// ... hier passiert irgendwas
*ptr_a = 10;
// Prüfung auf gültige Adresse
// if (ptr_a != NULL) *ptr_a = 10;
cout<<"Pointer ptr_a "<<ptr_a<<"\n";
Expand Down Expand Up @@ -670,11 +674,11 @@ using namespace std;

int main(void)
{
int a = 1; // Variable
int &r = a; // Referenz auf die Variable a
int a = 1; // Variable
int &r = a; // Referenz auf die Variable a

std::cout << "a: " << a << " r: " << r << std::endl;
std::cout << "a: " << &a << " r: " << &r << std::endl;
std::cout << "a: " << a << " r: " << r << std::endl;
std::cout << "a: " << &a << " r: " << &r << std::endl;
}
```
@LIA.eval(`["main.cpp"]`, `g++ -Wall main.cpp -o a.out`, `./a.out`)
Expand Down

0 comments on commit f089b24

Please sign in to comment.