aufgabenstellung erfüllt, muss noch die funktionen richtig machen

This commit is contained in:
Tobias Kachel 2026-04-08 12:42:15 +02:00
parent 08d8778929
commit 5fa8a68108
2 changed files with 38 additions and 34 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
1_Grundlagen/code/matrix.exe

View File

@ -3,18 +3,18 @@
int main()
{
const int nx=3;
const int nx = 1;
const int ny = 2;
const int nz = 3;
int ***matrix;
matrix = (int***)malloc((ny*sizeof(int**)*nz*sizeof(int)));
matrix = (int ***)malloc(nz * sizeof(int **));
for (int z = 0; z < nz; z++)
{
matrix[z] = (int **)malloc(ny * sizeof(int *));
for (int y = 0; y < ny; y++)
{
matrix[y] = (int**)malloc(nx*sizeof(int));
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;
@ -31,11 +31,14 @@ int main()
}
printf("\n");
}
printf("\n");
}
for(int z=0; z<ny; z++)
for (int z = 0; z < nz; z++)
{
for (int y = 0; y < ny; y++)
{
free(matrix[z][y]);
}
free(matrix[z]);
}
free(matrix);