알고리즘/SWEA
[SWEA] 1225. [S/W 문제해결 기본] 7일차 - 암호생성기
Ellie67
2022. 11. 10. 15:35
https://swexpertacademy.com/main/main.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
Queue를 사용해서 쉽게 풀 수 있었던 문제
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class P1225 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T = 1;
for(int t=1; t<=T; t++){
int tc = sc.nextInt();
Queue<Integer> q = new LinkedList<>();
for(int i=0; i<8; i++){
q.offer(sc.nextInt());
}
for(int i=1; i<=5; i++){
int x = q.poll()-i;
if(x<=0){
q.add(0);
break;
} else q.add(x);
if(i==5){
i=0;
}
}
System.out.print("#"+tc+" ");
for(int k : q) System.out.print(k+" ");
System.out.println();
}
}
}