난 정말 최고야 멋있어
백준 알고리즘 기초강의 2 -2 큐 덱 문자열 본문
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
Queue<Integer> q = new LinkedList<>();
int n = sc.nextInt();
int k = sc.nextInt();
for (int i = 1 ; i <= n; i++){
q.offer(i);
}
int i = 1;
System.out.print("<");
while (!q.isEmpty()){
int j = q.poll();
if ( i % k == 0){
System.out.print(j);
if (!q.isEmpty())
System.out.print(", ");
}
else{
q.offer(j);
}
i++;
}
System.out.println(">");
}
}
기초 자료구조인 큐와 덱과 문자열에 대해 배웠따
딱히 문제를 푼건 조세푸스 순열밖에 없다..
'하루 1공부' 카테고리의 다른 글
백준 알고리즘 기초강의 3 - 2 (0) | 2021.02.05 |
---|---|
백준 알고리즘 기초강의 2 스택 (0) | 2021.02.01 |
백준 알고리즘 기초 강의 1 입출력 (0) | 2021.01.31 |
줄세우기 위상정렬 with 큐 (0) | 2021.01.30 |
퇴사 (0) | 2021.01.27 |