프로그래밍

프로그래머스 C# 행렬의 덧셈(GetLength, 이중 배열 덧셈)

노마드선샤인 2023. 1. 23. 22:00
728x90

public class Solution {
    public int[,] solution(int[,] arr1, int[,] arr2) {
        int[,] answer = new int[arr1.GetLength(0),arr1.GetLength(1)];
        
        for(int i=0;i<arr1.GetLength(0);i++)
        {
            for(int j=0;j<arr2.GetLength(1);j++)
            {
                answer[i,j] = arr1[i,j] + arr2[i,j];   
            }
        }
        
        return answer;
    }
}

728x90