말랑한 하루
[SW Expert Academy] 3499 퍼펙트 셔플 [Java] 본문
반응형
[ Java ]
import java.util.Scanner;
public class _3499_퍼펙트_셔플 {
static void init() {
Scanner sc = new Scanner(System.in);
int tc = sc.nextInt();
for(int t=1;t<=tc;t++) {
int suffle = sc.nextInt();
int half = suffle/2;
String card[] = new String[suffle];
for(int i=0;i<suffle;i++)
card[i] = sc.next();
String first[] = new String[half];
for(int i=0;i<half;i++) first[i] = card[i];
String second[] = new String[half];
if (suffle %2 == 0)
for(int i=half;i<suffle;i++) second[i-half] = card[i];
else
for(int i=half+1;i<suffle;i++) second[i-half-1] = card[i];
System.out.print("#"+t+" ");
for(int i=0;i<half;i++)
System.out.print(first[i]+" "+second[i]+" ");
if (suffle %2 != 0)
System.out.print(card[half]);
System.out.println();
}
}
public static void main(String[] args) {
init();
}
}
반응형
'문제풀이 > SWexpert Academy' 카테고리의 다른 글
[SW Expert Academy] 2819 격자판의 숫자이어 붙이기 [Java] (0) | 2021.02.08 |
---|---|
[SW Expert Academy] 1494 사랑의 카운슬러 [Java] (0) | 2021.02.08 |
[SW Expert Academy] 1861 정사각형 방 [Java] (0) | 2021.02.07 |
[SW Expert Academy] 1224 계산기 3 [Java] (0) | 2021.02.07 |
[SW Expert Academy] 1223 계산기 2 [Java] (0) | 2021.02.07 |
Comments