Notice
Recent Posts
Recent Comments
Link
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags more
Archives
Today
Total
관리 메뉴

난 정말 최고야 멋있어

백준 알고리즘 기초강의 2 -2 큐 덱 문자열 본문

하루 1공부

백준 알고리즘 기초강의 2 -2 큐 덱 문자열

n00bh4cker 2021. 2. 3. 22:23
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