summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortwoexem <twoexem@gmail.com>2025-01-26 15:28:25 +0100
committertwoexem <twoexem@gmail.com>2025-01-26 15:28:25 +0100
commitae6707a9c757f666659868cab36cf178c0edc476 (patch)
treefd078e01972ace17dd7e3b5375c8b2dd7f8bbfa8
Initiales Commit, beinhaltet Aufg. 10.1 und 10.2
-rw-r--r--.vscode/launch.json7
-rw-r--r--.vscode/settings.json4
-rw-r--r--.vscode/tasks.json28
-rwxr-xr-xoutput/Übungbin0 -> 64800 bytes
-rw-r--r--Übung.c80
5 files changed, 119 insertions, 0 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..5c7247b
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,7 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": []
+} \ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..c85607f
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,4 @@
+{
+ "C_Cpp.errorSquiggles": "enabled",
+ "editor.cursorStyle": "line"
+} \ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..6fceb47
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,28 @@
+{
+ "tasks": [
+ {
+ "type": "cppbuild",
+ "label": "C/C++: gcc Aktive Datei kompilieren",
+ "command": "/usr/bin/gcc",
+ "args": [
+ "-fdiagnostics-color=always",
+ "-g",
+ "${file}",
+ "-o",
+ "${fileDirname}/${fileBasenameNoExtension}"
+ ],
+ "options": {
+ "cwd": "${fileDirname}"
+ },
+ "problemMatcher": [
+ "$gcc"
+ ],
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ },
+ "detail": "Vom Debugger generierte Aufgabe."
+ }
+ ],
+ "version": "2.0.0"
+} \ No newline at end of file
diff --git a/output/Übung b/output/Übung
new file mode 100755
index 0000000..df22e20
--- /dev/null
+++ b/output/Übung
Binary files differ
diff --git a/Übung.c b/Übung.c
new file mode 100644
index 0000000..1095728
--- /dev/null
+++ b/Übung.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <stdbool.h>
+#include <math.h>
+#include <stdlib.h>
+
+#define RED "\x1b[31m"
+#define GREEN "\x1b[32m"
+#define YELLOW "\x1b[33m"
+#define BLUE "\x1b[34m"
+#define MAGENTA "\x1b[35m"
+#define CYAN "\x1b[36m"
+#define RESET "\x1b[0m"
+
+void aufg_10_1();
+void aufg_10_2();
+
+int main() {
+ // Definieren
+ int auswahl;
+
+ // Wilkommenstext und Auswahl
+ printf(GREEN "--- " RESET MAGENTA "Wilkommen zu den " RESET BLUE "Informatikübungen " RESET "von Milan! ---\n");
+ printf("Nummer ohne Punkt" CYAN "(bsp: 101 für 10.1)" RESET "für Aufgabe eingeben!\n");
+ scanf("%d", &auswahl);
+
+ // Switch-Statement für Aufgabenauswahl
+ switch (auswahl) {
+ case 101: aufg_10_1();
+ case 102: aufg_10_2();
+ default: printf("Falsche Eingabe!");
+ }
+
+ return 0x0;
+}
+
+void aufg_10_1() {
+ // Arrays definieren
+ int a[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+ int b[11];
+
+ // Integer für For-Schleife definieren
+ int n, i;
+
+ // For-Schleife, die in 10 Durchgängen das Array rotiert
+ for(n = 0, i = 10 ; n <= 10; n++, i--) {
+ b[n] = a[i];
+
+ // Ausgabe der Werte der Arrays zur Kontrolle
+ // Array b (grün) ist das fertig rotierte Array
+ printf( RED "\nSpeicherzelle %d von Array A: %d" RESET, n, a[n]);
+ printf( GREEN "\nSpeicherzelle %d von Array B: %d" RESET, n, b[n]);
+ }
+
+ exit(0);
+}
+
+void aufg_10_2() {
+ // Arrays definieren
+ int a[11] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
+
+ // Abfragen, welches Element entfernt werden soll
+ int entf;
+ printf("Welches Element entfernen?");
+ scanf("%d", &entf);
+
+ // For-Schleife, die ab dem gewollten Element das Array verschiebt
+ while(entf <= 10) {
+ a[entf] = a[entf+1];
+ entf++;
+ }
+
+ // Ausgabe des Arrays
+ int n;
+ for(n = 0; n <= sizeof(a); n++) {
+ printf("%d", a[n]);
+ }
+ printf("\n");
+
+ exit(0);
+} \ No newline at end of file