프로그래머스_C#/Level_2
[프로그래머스 C#] 행렬의 곱셈
최애뎡
2021. 10. 26. 22:47
728x90
반응형
https://programmers.co.kr/learn/courses/30/lessons/12949
코딩테스트 연습 - 행렬의 곱셈
[[2, 3, 2], [4, 2, 4], [3, 1, 4]] [[5, 4, 3], [2, 4, 1], [3, 1, 1]] [[22, 22, 11], [36, 28, 18], [29, 20, 14]]
programmers.co.kr
public class Solution {
public int[,] solution(int[,] arr1, int[,] arr2) {
int[,] answer = new int[arr1.GetLength(0), arr2.GetLength(1)];
for (int i = 0; i < arr1.GetLength(0); i++)
for (int j = 0; j < arr2.GetLength(1); j++)
for (int x = 0; x < arr1.GetLength(1); x++)
answer[i, j] += arr1[i, x] * arr2[x, j];
return answer;
}
}
행렬 곱셈!
반응형