코딩테스트/[C#] 프로그래머스
[프로그래머스 | C# | Lv.0] 2차원으로 만들기
냠냠쿠
2023. 10. 3. 21:01
728x90
https://school.programmers.co.kr/learn/courses/30/lessons/120842
📝 나의 풀이
using System;
public class Solution {
public int[,] solution(int[] num_list, int n) {
int[,] answer = new int[(num_list.Length/n), n];
int x = 0;
int y = 0;
for(int i=0; i<num_list.Length; i++)
{
answer[x, y] = num_list[i];
y++;
if(y == n)
{
x++;
y = 0;
}
}
return answer;
}
}
728x90