[알고리즘/SWEA] #1228 암호문1

JudyLia·2022년 2월 8일
0

알고리즘

목록 보기
25/61
post-thumbnail
package algorithm_lab.day04.q2;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner;

public class Solution {
	public static void main(String[] args) throws NumberFormatException, IOException {
		System.setIn(new FileInputStream("./src/algorithm_lab/day04/q2/input.txt"));
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		
		for(int T=1;T<=10;T++) {
			int length = sc.nextInt();
			sc.nextLine();
			LinkedList<Integer> list = new LinkedList<Integer>();
			for(int i=0;i<length;i++) {
				list.add(sc.nextInt());
			}
			sc.nextLine();
			int ord_len=sc.nextInt();
			sc.nextLine();
			
			for(int i=0;i<ord_len;i++) {
				sc.next();
				int idx = sc.nextInt();
				int num = sc.nextInt();
				
				for(int j=0; j<num;j++) {
					list.add(idx,sc.nextInt());
					idx++;
				}
				
			}
			sb.append("#").append(T).append(" ");
			for(int i=0;i<10;i++) {
				if(list.isEmpty()) break;
				sb.append(list.poll()).append(" ");
			}
			sb.append("\n");
			
		}
		System.out.print(sb.toString());
	}
}
profile
안녕:)

0개의 댓글

관련 채용 정보