hab 1 augabe fertig, bin zu dumm das auf windows zu kompilieren deswegen mal schauen
This commit is contained in:
parent
5fa8a68108
commit
5d78ae3349
28
.vscode/tasks.json
vendored
Normal file
28
.vscode/tasks.json
vendored
Normal file
@ -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"
|
||||||
|
}
|
||||||
@ -1,14 +1,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "matrix.h"
|
||||||
|
|
||||||
int main()
|
int ***build_matrix(int nx, int ny, int nz)
|
||||||
{
|
{
|
||||||
const int nx = 1;
|
int ***matrix = (int ***)malloc(nz * sizeof(int **));
|
||||||
const int ny = 2;
|
|
||||||
const int nz = 3;
|
|
||||||
int ***matrix;
|
|
||||||
|
|
||||||
matrix = (int ***)malloc(nz * sizeof(int **));
|
|
||||||
for (int z = 0; z < nz; z++)
|
for (int z = 0; z < nz; z++)
|
||||||
{
|
{
|
||||||
matrix[z] = (int **)malloc(ny * sizeof(int *));
|
matrix[z] = (int **)malloc(ny * sizeof(int *));
|
||||||
@ -17,10 +13,15 @@ int main()
|
|||||||
matrix[z][y] = (int *)malloc(nx * sizeof(int));
|
matrix[z][y] = (int *)malloc(nx * sizeof(int));
|
||||||
for (int x = 0; x < nx; x++)
|
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 z = 0; z < nz; z++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < ny; y++)
|
for (int y = 0; y < ny; y++)
|
||||||
@ -32,7 +33,10 @@ int main()
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_matrix(int ***matrix, int ny, int nz)
|
||||||
|
{
|
||||||
for (int z = 0; z < nz; z++)
|
for (int z = 0; z < nz; z++)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < ny; y++)
|
for (int y = 0; y < ny; y++)
|
||||||
|
|||||||
6
1_Grundlagen/code/matrix.h
Normal file
6
1_Grundlagen/code/matrix.h
Normal file
@ -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);
|
||||||
Loading…
x
Reference in New Issue
Block a user