Compare commits
No commits in common. "adec5664828e419441678d63923b9fe3383a9118" and "35311c2eca21831120a2b0b985fd56f1c98ef041" have entirely different histories.
adec566482
...
35311c2eca
@ -1,65 +0,0 @@
|
|||||||
//Ablage für ChatGPT Sachen, nicht relavant für das Projekt (Nur ein "Cloud"-Zwischenspeicher)
|
|
||||||
// Created by gamer on 09.11.2025.
|
|
||||||
//
|
|
||||||
#include <iostream>
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
// Typalias für 4x4-Matrix mit double
|
|
||||||
using Matrix4x4 = std::array<std::array<double, 4>, 4>;
|
|
||||||
|
|
||||||
// Matrixmultiplikation: C = A * B
|
|
||||||
Matrix4x4 matmul(const Matrix4x4& A, const Matrix4x4& B) {
|
|
||||||
Matrix4x4 C = {}; // Alle Werte automatisch 0
|
|
||||||
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
for (int j = 0; j < 4; ++j) {
|
|
||||||
for (int k = 0; k < 4; ++k) {
|
|
||||||
C[i][j] += A[i][k] * B[k][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return C;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Matrixeinlesung vom Benutzer
|
|
||||||
Matrix4x4 inputMatrix(const std::string& name) {
|
|
||||||
Matrix4x4 M = {};
|
|
||||||
std::cout << "Bitte Werte für Matrix " << name << " (4x4) eingeben:\n";
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
for (int j = 0; j < 4; ++j) {
|
|
||||||
std::cout << name << "[" << i << "][" << j << "]: ";
|
|
||||||
std::cin >> M[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return M;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Matrixausgabe
|
|
||||||
void printMatrix(const Matrix4x4& M) {
|
|
||||||
for (int i = 0; i < 4; ++i) {
|
|
||||||
for (int j = 0; j < 4; ++j) {
|
|
||||||
std::cout << M[i][j] << "\t";
|
|
||||||
}
|
|
||||||
std::cout << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
// Benutzerinput
|
|
||||||
Matrix4x4 A = inputMatrix("A");
|
|
||||||
Matrix4x4 B = inputMatrix("B");
|
|
||||||
|
|
||||||
// Multiplikation
|
|
||||||
Matrix4x4 C = matmul(A, B);
|
|
||||||
|
|
||||||
// Ausgabe
|
|
||||||
std::cout << "\nErgebnis der Matrixmultiplikation (C = A * B):\n";
|
|
||||||
printMatrix(C);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//das ist statisch. Matrix A und B sollen von User als input gegeben werden
|
|
||||||
Loading…
x
Reference in New Issue
Block a user