코딩테스트/[C#] 프로그래머스

[프로그래머스 | C# | Lv.0] 특별한 이차원 배열 1

냠냠쿠 2023. 9. 6. 19:57
728x90

https://school.programmers.co.kr/learn/courses/30/lessons/181833

📝 나의 풀이

using System;

public class Solution {
    public int[,] solution(int n) {
        int[,] answer = new int[n,n];
        
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                if(i==j) {
                    answer[i,j]=1;
                }
            }
        }
        return answer;
    }
}
728x90