반응형
깃 링크 : 바로가기
링크 : 바로가기
1차시도
using System.Text;
public class num_10871
{
public static void Main()
{
string[] input = Console.ReadLine().Split();
int N = int.Parse(input[0]);
int X = int.Parse(input[1]);
string[] A = Console.ReadLine().Split();
int[] arr = new int[N];
StringBuilder result = new StringBuilder();
for (int i = 0; i < N; i++)
{
int value = int.Parse(A[i]);
arr[i] = value;
if(value < X)
{
result.AppendFormat("{0} ",value);
}
}
Console.WriteLine(result.ToString());
}
}
결과
- 입력 값에 맞춰 배열을 만들어 준 후 X값보다 작은 것들을 StringBuilder에 담아 출력
반응형
'기타 > 코딩테스트 공부' 카테고리의 다른 글
[백준] 알고리즘 수업 - 알고리즘의 수행 시간 2 - 24263번 (0) | 2025.05.02 |
---|---|
[백준] 알고리즘 수업 - 알고리즘의 수행 시간 1 - 24262번 (0) | 2025.05.02 |
[백준] 개수 세기 - 10807번 (0) | 2025.05.01 |
[백준] A+B(4) - 10951번 (0) | 2025.05.01 |
[백준] A+B(5) - 10952번 (0) | 2025.05.01 |