initial commit

This commit is contained in:
2026-04-09 15:03:00 +02:00
commit c978250c80
44 changed files with 1277 additions and 0 deletions
Binary file not shown.
+35
View File
@@ -0,0 +1,35 @@
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include "matrix.h"
int main()
{
// First example
int nz=3;
int nx=3;
int ny=3;
int*** matrix = build_matrix(nx, ny, nz);
assert(matrix[0][0][0] == 111 && "matrix[0][0][0] must be 111 after assignment");
assert(matrix[2][2][2] == 333 && "matrix[2][2][2] must be 333 after assignment");
print_matrix(matrix, nx, ny, nz);
free_matrix(matrix, ny, nz);
nz=3;
nx=1;
ny=2;
// Second example
matrix = build_matrix(nx, ny, nz);
assert(matrix[0][0][0] == 111 && "matrix[0][0][0] must be 111 after assignment");
assert(matrix[2][1][0] == 321 && "matrix[2][1][0] must be 321 after assignment");
print_matrix(matrix, nx, ny, nz);
free_matrix(matrix, ny, nz);
}
+5
View File
@@ -0,0 +1,5 @@
#include "linker.h"
void ausgabe(int ausgabeWert){
std::cout << "Ausgabe" << ausgabeWert;
}
+11
View File
@@ -0,0 +1,11 @@
#include <iostream>
using namespace std;
int main() {
int fehler;
cout << fehler
}
//AsemblerCode mit -S und erzeugteDatei.s
+6
View File
@@ -0,0 +1,6 @@
int main(){
int array[3];
for(int i = 0; i <= 3; i++){ //Es wird außerhalb des Arrays geschrieben -> Laufzeitfehler
array[i] = i;
}
}
+7
View File
@@ -0,0 +1,7 @@
#include "linker.h"
int main(){
int ausgabeWert = 1;
ausgabe(ausgabeWert); //Falscher Funktionsname
}
+3
View File
@@ -0,0 +1,3 @@
#include <iostream>
void ausgabe(int ausgabeWert);
@@ -0,0 +1,8 @@
#include <iostream>
#include "fehler.h" //Nicht benötigte Datei entfernen, Fehler da Datei nicht existiert
using namespace std;
int main(){
cout << "Dies ist ein präporzessor Fehler";
}
+60
View File
@@ -0,0 +1,60 @@
#include <stdio.h>
#include <stdlib.h>
#include "matrix.h"
int ***build_matrix(int nx, int ny, int nz)
{
int ***matrix;
matrix = (int ***)malloc(nz * sizeof(int **));
if(!matrix)
return 0;
for (int z = 0; z < nz; z++)
{
matrix[z] = (int **)malloc(ny * sizeof(int *));
if(!matrix[z])
return 0;
for (int y = 0; y < ny; y++)
{
matrix[z][y] = (int *)malloc(nx * sizeof(int));
if(!matrix[z][y])
return 0;
for (int x = 0; x < nx; x++)
{
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++)
{
for (int x = 0; x < nx; x++)
{
printf("%i ", matrix[z][y][x]);
}
printf("\n");
}
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++)
{
free(matrix[z][y]);
}
free(matrix[z]);
}
free(matrix);
}
+8
View File
@@ -0,0 +1,8 @@
#ifndef MATRIX_H
#define MATRIX_H
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);
#endif