SWEA_2005) 파스칼의 삼각형
SWEA
# D2
2005) 파스칼의 삼각형 (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
|
import java.io.*;
public class Solution {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(br.readLine());
for(int i=1;i<=t;i++) {
int n = Integer.parseInt(br.readLine());
bw.write("#" + i + "\n");
for(int p=0;p<n;p++) {
for(int q=0;q<=p;q++) {
if(p==q || q==0) bw.write("1 ");
else bw.write(p + " ");
}
bw.write("\n");
}
}
bw.flush();
bw.close();
}
}
| cs |
댓글
댓글 쓰기