aufgabenstellung erfüllt, muss noch die funktionen richtig machen
This commit is contained in:
parent
08d8778929
commit
5fa8a68108
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
1_Grundlagen/code/matrix.exe
|
||||
@ -1,41 +1,44 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
const int nx=3;
|
||||
const int ny=2;
|
||||
const int nz=3;
|
||||
int*** matrix;
|
||||
const int nx = 1;
|
||||
const int ny = 2;
|
||||
const int nz = 3;
|
||||
int ***matrix;
|
||||
|
||||
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 z=0; z<ny; z++)
|
||||
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[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
for (int z = 0; z < nz; z++)
|
||||
{
|
||||
for (int y = 0; y < ny; y++)
|
||||
{
|
||||
free(matrix[z][y]);
|
||||
}
|
||||
free(matrix[z]);
|
||||
}
|
||||
free(matrix);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user