diff --git a/matrix_product/main.cpp b/matrix_product/main.cpp new file mode 100644 index 0000000..d8ab3ba --- /dev/null +++ b/matrix_product/main.cpp @@ -0,0 +1,36 @@ + +#include +#include +#include + +int main() +{ + int aMatrix[3][2] = {{1, 4}, {2, 5}, {3, 6}}; + int bMatrix[2][3] = {{7, 8, 9}, {10, 11, 12}}; + int product[3][3] = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}; + + for (int row = 0; row < 3; row++) + { + for (int col = 0; col < 3; col++) + { + for (int temp = 0; temp < 2; temp++) + { + product[row][col] += aMatrix[row][temp] * bMatrix[temp][col]; + /* code */ + } + + if (row == 0 && col == 0) + { + std::cout << "Product:\n"; + std::cout << product[row][col] << " "; + } + else + { + std::cout << product[row][col] << " "; + } + } + std::cout << "\n"; + } + + return 0; +} \ No newline at end of file diff --git a/matrix_product/makefile b/matrix_product/makefile new file mode 100644 index 0000000..d6a755f --- /dev/null +++ b/matrix_product/makefile @@ -0,0 +1,5 @@ +dev: compile run +compile: + g++ -o matrix main.cpp +run: + ./matrix \ No newline at end of file diff --git a/matrix_product/matrix b/matrix_product/matrix new file mode 100755 index 0000000..144bc6e Binary files /dev/null and b/matrix_product/matrix differ