From 5d78ae33497e9dd836616e52fb74415da58760f9 Mon Sep 17 00:00:00 2001 From: kachelto100370 Date: Thu, 9 Apr 2026 17:09:13 +0200 Subject: [PATCH] hab 1 augabe fertig, bin zu dumm das auf windows zu kompilieren deswegen mal schauen --- .vscode/tasks.json | 28 ++++++++++++++++++++++++++++ 1_Grundlagen/code/matrix.cpp | 22 +++++++++++++--------- 1_Grundlagen/code/matrix.h | 6 ++++++ 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 .vscode/tasks.json create mode 100644 1_Grundlagen/code/matrix.h diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..f834a88 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,28 @@ +{ + "tasks": [ + { + "type": "cppbuild", + "label": "C/C++: x86_64-w64-mingw32-gcc.exe build active file", + "command": "c:\\Users\\tobis\\mingw64\\bin\\x86_64-w64-mingw32-gcc.exe", + "args": [ + "-fdiagnostics-color=always", + "-g", + "${file}", + "-o", + "${fileDirname}\\${fileBasenameNoExtension}.exe" + ], + "options": { + "cwd": "c:\\Users\\tobis\\mingw64\\bin" + }, + "problemMatcher": [ + "$gcc" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Task generated by Debugger." + } + ], + "version": "2.0.0" +} \ No newline at end of file diff --git a/1_Grundlagen/code/matrix.cpp b/1_Grundlagen/code/matrix.cpp index 41e02ad..7c2448d 100644 --- a/1_Grundlagen/code/matrix.cpp +++ b/1_Grundlagen/code/matrix.cpp @@ -1,14 +1,10 @@ #include #include +#include "matrix.h" -int main() +int ***build_matrix(int nx, int ny, int nz) { - const int nx = 1; - const int ny = 2; - const int nz = 3; - int ***matrix; - - matrix = (int ***)malloc(nz * sizeof(int **)); + int ***matrix = (int ***)malloc(nz * sizeof(int **)); for (int z = 0; z < nz; z++) { matrix[z] = (int **)malloc(ny * sizeof(int *)); @@ -17,10 +13,15 @@ int main() matrix[z][y] = (int *)malloc(nx * sizeof(int)); for (int x = 0; x < nx; x++) { - matrix[z][y][x] =(z + 1) * 100 + (y + 1) * 10 + x + 1; + matrix[z][y][x] = (z + 1) * 100 + (y + 1) * 10 + x + 1; } } } + return matrix; +} + +void print_matrix(int ***matrix, int nx, int ny, int nz) +{ for (int z = 0; z < nz; z++) { for (int y = 0; y < ny; y++) @@ -32,7 +33,10 @@ int main() printf("\n"); } } +} +void free_matrix(int ***matrix, int ny, int nz) +{ for (int z = 0; z < nz; z++) { for (int y = 0; y < ny; y++) @@ -42,4 +46,4 @@ int main() free(matrix[z]); } free(matrix); -} +} \ No newline at end of file diff --git a/1_Grundlagen/code/matrix.h b/1_Grundlagen/code/matrix.h new file mode 100644 index 0000000..3225121 --- /dev/null +++ b/1_Grundlagen/code/matrix.h @@ -0,0 +1,6 @@ +#pragma once + + +int ***build_matrix(int nx, int ny, int nz); +void print_matrix(int ***matrix, int nx, int ny, int nz); +void free_matrix(int ***matrix, int ny, int nz); \ No newline at end of file