using System;
using System.Collections.Generic;
public class Solution {
public int[] solution(int n) {
List<int> list = new List<int>();
for(int i = 1; i <= n; i++)
{
if(i % 2 == 1)
{
list.Add(i);
}
}
int[] answer = new int[list.Count];
for(int i = 0; i < list.Count; i++)
{
answer[i] = list[i];
}
return answer;
}
}
'프로그래머스 > Lv.0' 카테고리의 다른 글
[프로그래머스 C#] 길이에 따른 연산 (0) | 2023.08.05 |
---|---|
[프로그래머스 C#] 공배수 (0) | 2023.08.05 |
[프로그래머스 C#] 중앙값 구하기 (0) | 2023.08.04 |
[프로그래머스 C#] 특정 문자 제거하기 (0) | 2023.08.03 |
[프로그래머스 C#] 숨어있는 숫자의 덧셈(1) (0) | 2023.08.02 |