본문 바로가기

Algorithms/SW Expert Academy

[Java] SW Expert Academy 1228번 문제: [S/W 문제해결 기본] 8일차 - 암호문1 (LinkedList)

--- 문제 ---

 

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

 

--- 코드 ---

 

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

public class Sw1228 {

	public static void main(String[] args) throws FileNotFoundException {
		
		
		System.setIn(new FileInputStream("./src/1228.txt"));

		Scanner sc = new Scanner(System.in);
		int T;
		T=10;
				
		for(int test_case = 1; test_case <= T; test_case++) {
			
			
			int N  = sc.nextInt();
			
			LinkedList<String> ten = new LinkedList();
			for(int i=0; i<N; ++i) {
				ten.add(sc.next());
			}
			
			int cm = sc.nextInt();
			
			for(int c=0; c<cm ; ++c) {
				
				sc.next();
				int start = sc.nextInt();
				int iter = sc.nextInt();
				
				for(int r=0; r<iter; ++r) {
					if(start<10) {
						ten.add(start, sc.next());
						ten.pollLast();
						start++;
					}
					else {
						sc.next();
					}
				}
					
			}
			System.out.printf("#%d ",test_case);
			for(int i=0; i<10; ++i) {
				System.out.printf("%s ",ten.get(i));
			}
			System.out.println();
			
			
		}
		
		
	}

}

 

 

--- 출처 --- 

 

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

 

반응형