728x90
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWGsRbk6AQIDFAVW
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for(int t=1; t<=T; t++) {
int card = sc.nextInt();
StringBuilder sb = new StringBuilder();
int preCard = (card%2==0) ? card/2 : card/2 +1;
int postCard = card-preCard;
String[] sPre = new String[preCard];
String[] sPost = new String[postCard];
for(int i=0; i<preCard; i++) {
sPre[i] = sc.next();
}
for(int i=0; i<postCard; i++) {
sPost[i] = sc.next();
}
sb.append("#").append(t).append(" ");
for(int i=0; i<card/2; i++) {
sb.append(sPre[i]).append(" ").append(sPost[i]).append(" ");
}
if(card%2!=0) sb.append(sPre[sPre.length-1]);
System.out.println(sb.toString());
}
}
}
728x90
'[알고리즘] > 알고리즘' 카테고리의 다른 글
[알고리즘] 백준 1991. 트리순회 (0) | 2022.02.13 |
---|---|
[알고리즘] 백준 2309번 일곱 난쟁이 (0) | 2022.02.13 |
[알고리즘] 백준 17478. 재귀함수가 뭔가요? (0) | 2022.02.13 |
[알고리즘] 백준 10974. 모든 순열 (0) | 2022.02.13 |
[알고리즘] 백준6603. 로또 (0) | 2022.02.13 |