SWEA 3499 퍼펙트 셔플

1 개요[ | ]

SWEA 3499 퍼펙트 셔플
SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 3-4

2 C++[ | ]

3 Java[ | ]

import java.io.*;
import java.util.*;
public class Solution {
	public static void main(String[] args) throws IOException {
    	Scanner sc = new Scanner(System.in);
    	BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    	int T = sc.nextInt();
    	for(int tc=1; tc<=T; tc++) {
    		bw.append("#" + String.valueOf(tc) + " ");
    		int N = sc.nextInt();
    		String[] deck = new String[N];
    		for(int i=0; i<N; i++) {
    			deck[i] = sc.next();
    		}
    		int half = N/2;
    		int remain = N%2;
    		for(int i=0; i<half; i++) {
    			bw.append( deck[i] + " " + deck[remain+half+i] + " " );
    		}
    		if( remain > 0 ) bw.append( deck[half] ); 
    		bw.append("\n");
        }
		bw.flush();
        sc.close();
    }
}

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}