diff options
| author | Syndamia <kamen@syndamia.com> | 2023-12-03 13:33:32 +0200 |
|---|---|---|
| committer | Syndamia <kamen@syndamia.com> | 2023-12-03 13:33:32 +0200 |
| commit | 0996e05988b5d38faba0f616f06e6dcc7466930e (patch) | |
| tree | 5efa650f38dddfaf0a1389a2cb2f4075bb76e8d8 /week06/ex1.cpp | |
| parent | ebccf5fed44edd6f0971852701708259e855cd17 (diff) | |
| download | upp-2023-solutions-0996e05988b5d38faba0f616f06e6dcc7466930e.tar upp-2023-solutions-0996e05988b5d38faba0f616f06e6dcc7466930e.tar.gz upp-2023-solutions-0996e05988b5d38faba0f616f06e6dcc7466930e.zip | |
[w6] Added solutions for ex1 and ex2 with partials for ex3 and 4
Diffstat (limited to 'week06/ex1.cpp')
| -rw-r--r-- | week06/ex1.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/week06/ex1.cpp b/week06/ex1.cpp new file mode 100644 index 0000000..36938b7 --- /dev/null +++ b/week06/ex1.cpp @@ -0,0 +1,41 @@ +#include <iostream> + +int main() { + // Вход + size_t N, M; + std::cin >> N >> M; + + int matrix1[60][60], matrix2[60][60]; + /* При matrix1[i][j] няма значение дали i се води ред или стълб, важното е да + * изберете едно значение и то да си стои до края на задачата. + */ + for (size_t row = 0; row < N; row++) { + for (size_t col = 0; col < M; col++) { + std::cin >> matrix1[row][col]; + } + } + + for (size_t row = 0; row < M; row++) { + for (size_t col = 0; col < N; col++) { + std::cin >> matrix2[row][col]; + } + } + + // Умножение + int multMatrix[60][60] = { { 0 } }; + for (size_t row = 0; row < N; row++) { + for (size_t col = 0; col < N; col++) { + for (size_t i = 0; i < 60; i++) { + multMatrix[row][col] += matrix1[row][i] * matrix2[i][col]; + } + } + } + + // Изход + for (size_t row = 0; row < N; row++) { + for (size_t col = 0; col < N; col++) { + std::cout << multMatrix[row][col] << " "; + } + std::cout << std::endl; + } +} |
