Vorbereitungsaufgaben sind fertig

This commit is contained in:
2026-04-07 16:38:08 +02:00
parent 762dd4df86
commit 08d8778929
12 changed files with 53 additions and 25 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+29 -21
View File
@@ -5,30 +5,38 @@ int main()
{
const int nx=3;
const int ny=2;
int** matrix;
const int nz=3;
int*** matrix;
matrix = (int**)malloc(ny*sizeof(int*));
for(int y=0; y<ny; y++)
{
matrix[y] = (int*)malloc(nx*sizeof(int));
for(int x=0; x<nx; x++)
{
matrix[y][x] = (y+1)*10 + x+1;
}
}
for(int y=0; y<ny; y++)
{
for(int x=0; x<nx; x++)
{
printf("%i ",matrix[y][x]);
}
printf("\n");
}
matrix = (int***)malloc((ny*sizeof(int**)*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));
for(int x=0; x<nx; x++)
{
matrix[z][y][x] = (z+1) * 100 + (y+1)*10 + x+1;
}
}
}
for(int z=0; z<nz; z++)
{
for(int y=0; y<ny; y++)
{
for(int x=0; x<nx; x++)
{
printf("%i ",matrix[z][y][x]);
}
printf("\n");
}
printf("\n");
}
for(int y=0; y<ny; y++)
for(int z=0; z<ny; z++)
{
free(matrix[y]);
free(matrix[z]);
}
free(matrix);
}
BIN
View File
Binary file not shown.