-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathTPC05.java
More file actions
52 lines (44 loc) · 951 Bytes
/
TPC05.java
File metadata and controls
52 lines (44 loc) · 951 Bytes
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
public class TPC05 {
public static void main(String[] args) {
int[] a=new int[3];
a[0]=10;
a[1]=20;
a[2]=30;
int sum=0;
for(int i=0;i<a.length;i++) {
sum+=a[i];
}
System.out.println(sum);
// 9개의 정수형 변수를 만들어라.->2차원 구조
int[][] b=new int[3][3];
b[0][0]=1;
b[0][1]=2;
b[0][2]=3;
b[1][0]=1;
b[1][1]=2;
b[1][2]=3;
b[2][0]=1;
b[2][1]=2;
b[2][2]=3;
for(int i=0;i<b.length;i++) {
for(int j=0;j<b[i].length;j++) {
System.out.print(b[i][j]+"\t");
}
System.out.println();
}
// 가변길이 배열
int[][] star=new int[5][];
star[0]=new int[1];
star[1]=new int[2];
star[2]=new int[3];
star[3]=new int[4];
star[4]=new int[5];
for(int i=0;i<star.length;i++) {
for(int j=0;j<star[i].length;j++) {
star[i][j]='*';
System.out.print((char)star[i][j]);
}
System.out.println();
}
}
}