Website Summary Files Commits Branches @commit @diff @stats
path: root / Week08 / Exercise14.cpp
diff options
context:
space:
mode:
1 files changed, 25 insertions, 0 deletions
-rw-r--r--Week08/Exercise14.cpp25
diff --git a/Week08/Exercise14.cpp b/Week08/Exercise14.cpp
new file mode 100644
index 0000000..c224948
--- /dev/null
+++ b/Week08/Exercise14.cpp
@@ -0,0 +1,25 @@
+#include <iostream>
+
+int main() {
+ const unsigned int ROWS = 6, COLS = 3;
+
+ double vec[ROWS];
+ for (unsigned int i = 0; i < ROWS; i++)
+ std::cin >> vec[i];
+
+ double mat[ROWS][COLS];
+ for (unsigned int i = 0; i < ROWS; i++)
+ for (unsigned int j = 0; j < COLS; j++)
+ std::cin >> mat[i][j];
+
+ double mult[COLS] = { 0.0 };
+ for (unsigned int col = 0; col < COLS; col++)
+ for (unsigned int row = 0; row < ROWS; row++)
+ mult[col] += vec[row] * mat[row][col];
+
+ for (unsigned int i = 0; i < COLS; i++)
+ std::cout << mult[i] << ' ';
+ std::cout << std::endl;
+
+ return 0;
+}