SWEA_1961) 숫자 배열 회전
SWEA
# D2
1961) 숫자 배열 회전 (19.10.04)
문제 링크 (SW Expert Academy)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
import java.util.*;
import java.io.*;
public class Solution {
public static String one(int[][] arr, int j, int n) {
String s = "";
for(int i=n-1;i>=0; i--) {
s = s+arr[i][j];
}
return s;
}
public static String two(int[][] arr, int j, int n) {
String s = "";
for(int i=n-1;i>=0; i--) {
s = s+ arr[n-j-1][i];
}
return s;
}
public static String three(int[][] arr, int j, int n) {
String s = "";
for(int i=0;i<n; i++) {
s = s + arr[i][n-j-1];
}
return s;
}
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer tk;
int t = Integer.parseInt(br.readLine());
for(int i=1;i<=t;i++) {
int n = Integer.parseInt(br.readLine());
int[][] arr = new int[n][n];
for(int p=0;p<n;p++) {
tk = new StringTokenizer(br.readLine());
for(int q=0;q<n;q++) {
arr[p][q] = Integer.parseInt(tk.nextToken());
}
}
bw.write("#" + i + "\n");
for(int j=0;j<n;j++) {
bw.write(one(arr, j, n)+" ");
bw.write(two(arr, j, n)+" ");
bw.write(three(arr, j, n)+"\n");
}
}
bw.flush();
bw.close();
}
}
| cs |
NcuncverYcolge_2000 David Wallace Free Download
답글삭제soduparhigh