티스토리 뷰

1228. [S/W 문제해결 기본] 8일차 - 암호문1

swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV14w-rKAHACFAYD&categoryId=AV14w-rKAHACFAYD&categoryType=CODE&problemTitle=1228&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=&pageSize=10&pageIndex=1

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

import java.io.*;
import java.util.*;

// 210208 
public class Solution_D3_1228_암호문1 {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int T = 10;
		
		for (int tc=1; tc<=T; tc++) {
			
			StringBuilder sb = new StringBuilder();
			sb.append("#" + tc);
			
			int N = Integer.parseInt(br.readLine());
			StringTokenizer st = new StringTokenizer(br.readLine(), " ");
			
			LinkedList<String> list = new LinkedList<String>();
			list.add("head"); // 0번째

			for (int i=0; i<N; i++) {
				list.add(st.nextToken());
			}

			int M = Integer.parseInt(br.readLine()); // 명령어의 개수
			st = new StringTokenizer(br.readLine(), " ");
			
			for(int i=1; i<=M; i++) {
				String insert = st.nextToken(); // I 명령어
				int x = Integer.parseInt(st.nextToken()); // 암호문이 들어갈 위치
				int y = Integer.parseInt(st.nextToken()); // 추가될 암호문 길이
				
				int idx = x+1;
				for (int j=0; j<y; j++) {
					list.add(idx++, st.nextToken());
				}
			}
			
			// 출력
			for(int i=1; i<=10; i++) {
				sb.append(" " + list.get(i));
			}
	
			System.out.println(sb.toString());
		}

		br.close();
	}

}

 

 

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   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
글 보관함