createMatrix korrigiert und Tests bestanden

This commit is contained in:
schneidersi103495 committed 2026-11-08 16:48:42 +01:00
1 parent c44a06007a
commit 7c16f37648
2 files changed
+13 -3

No files matched your search

+11
View File
@@ -9,11 +9,22 @@ Matrix createMatrix(unsigned int rows, unsigned int cols)
Matrix matrix;
// Prüfen, ob eine Dimension 0 ist
if (rows == 0 || cols == 0) {
matrix.rows = 0;
matrix.cols = 0;
matrix.buffer = NULL;
return matrix;
}
// Zeilen und Spalten festlegen
matrix.rows = rows;
matrix.cols = cols;
// Speicher reservieren
matrix.buffer = calloc(rows * cols, sizeof(MatrixType));
//Prüfen ob die Speichereservierung fehlgeschlagen ist
if (matrix.buffer == NULL) {
matrix.rows = 0;
+2 -3
View File
@@ -7,12 +7,11 @@ typedef float MatrixType;
// TODO Matrixtyp definieren
typdef struct {
typedef struct {
MatrixType *buffer;
unsigned int rows;
unsigned int cols;
}Matrix;
} Matrix;
Matrix createMatrix(unsigned int rows, unsigned int cols);