From c8cc28cbe423c9ea5b7dafe286d7454ebd20ce93 Mon Sep 17 00:00:00 2001 From: danielvici123 <94993276+danielvici@users.noreply.github.com> Date: Wed, 27 Nov 2024 12:27:18 +0100 Subject: [PATCH] aufgabe, mitschrieb, anpassung Afgabe von progp, Mitschrieb von Porgp, Ordner umbennung --- .vscode/settings.json | 5 +- .../luca-quartal.php | 0 .../num_array.php | 124 ++++++++++++++++++ .../quartal-2.php | 0 .../quartal.php | 0 .../uebung_array_1.php | 17 +++ 6 files changed, 145 insertions(+), 1 deletion(-) rename progp/{24-11-27 => 24-11-27 -- arrays+aufgaben}/luca-quartal.php (100%) create mode 100644 progp/24-11-27 -- arrays+aufgaben/num_array.php rename progp/{24-11-27 => 24-11-27 -- arrays+aufgaben}/quartal-2.php (100%) rename progp/{24-11-27 => 24-11-27 -- arrays+aufgaben}/quartal.php (100%) create mode 100644 progp/24-11-27 -- arrays+aufgaben/uebung_array_1.php diff --git a/.vscode/settings.json b/.vscode/settings.json index 514156c..7667dd5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "livePreview.defaultPreviewPath": "/komp/24-10-11/index.html" + "livePreview.defaultPreviewPath": "/komp/24-10-11/index.html", + "cSpell.enabledFileTypes": { + "php": false + } } \ No newline at end of file diff --git a/progp/24-11-27/luca-quartal.php b/progp/24-11-27 -- arrays+aufgaben/luca-quartal.php similarity index 100% rename from progp/24-11-27/luca-quartal.php rename to progp/24-11-27 -- arrays+aufgaben/luca-quartal.php diff --git a/progp/24-11-27 -- arrays+aufgaben/num_array.php b/progp/24-11-27 -- arrays+aufgaben/num_array.php new file mode 100644 index 0000000..7127b5a --- /dev/null +++ b/progp/24-11-27 -- arrays+aufgaben/num_array.php @@ -0,0 +1,124 @@ + + +
+ + +"; +print_r($notenliste); +echo ""; + +// Einzelne Stellen eines Arrays ausgeben: +echo $notenliste[3]; // gibt 2.2 aus + +// Neuen Wert hinzufügen (an's Ende) +$notenliste[] = 6.0; +echo "
"; +print_r($notenliste); +echo ""; + +// Bestehenden Wert ändern (überschreiben) +$notenliste[2] = 4.2; +echo "
"; +print_r($notenliste); +echo ""; + +// Bestehenden Wert löschen +// Achtung: Index wird nicht neu erstellt (enspr. Index fehlt jetzt) +unset($notenliste[1]); +echo "
"; +print_r($notenliste); +echo ""; + +// Array sortieren (nach Werten sortieren) +sort($notenliste); // (Zuordnung index - value aufgelöst) +//asort ($noten_liste); +// assoziatives Sortieren (Zuordnung index - value bleibt erhalten) +echo "
"; +print_r($notenliste); +echo ""; + +// Benutzerfreundliche Ausgabe des Arrays +for($i = 0; $i < 5; $i++){ + echo "Note:".($i+1)." $notenliste[$i]
Durschnitt: $ds
"; + + +// Höchsten Wert ermitteln + // umständlich (ohne Funktion) +$schlechteste = 1.0; +for($i=0; $i < count($notenliste); $i++){ + if ($notenliste[$i] > $schlechteste){ + $schlechteste = $notenliste[$i]; + } +} +echo "Schlechteste Note: $schlechteste
"; + + // mit funktion +$schlechteste = max($notenliste); +echo "Schlechteste Note: $schlechteste
"; + + +// niedrigste Wert ermitteln + // umständlich (ohne Funktion) + $schlechteste = 6.0; + for($i=0; $i < count($notenliste); $i++){ + if ($notenliste[$i] < $schlechteste){ + $schlechteste = $notenliste[$i]; + } + } + echo "Schlechteste Note: $schlechteste
"; + + // mit funktion + $schlechteste = min($notenliste); + echo "Schlechteste Note: $schlechteste
"; +?> + + \ No newline at end of file diff --git a/progp/24-11-27/quartal-2.php b/progp/24-11-27 -- arrays+aufgaben/quartal-2.php similarity index 100% rename from progp/24-11-27/quartal-2.php rename to progp/24-11-27 -- arrays+aufgaben/quartal-2.php diff --git a/progp/24-11-27/quartal.php b/progp/24-11-27 -- arrays+aufgaben/quartal.php similarity index 100% rename from progp/24-11-27/quartal.php rename to progp/24-11-27 -- arrays+aufgaben/quartal.php diff --git a/progp/24-11-27 -- arrays+aufgaben/uebung_array_1.php b/progp/24-11-27 -- arrays+aufgaben/uebung_array_1.php new file mode 100644 index 0000000..bdff67b --- /dev/null +++ b/progp/24-11-27 -- arrays+aufgaben/uebung_array_1.php @@ -0,0 +1,17 @@ +"; + $zahlen[] = $random_zahl; +} +echo ""; +print_r($zahlen); +echo ""; + +?> \ No newline at end of file