Skip to content

Commit afd1083

Browse files
committed
updated program for Exercise01_04
1 parent 13b2c4f commit afd1083

File tree

1 file changed

+3
-40
lines changed

1 file changed

+3
-40
lines changed

ch_01/Exercise01_04.java

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,47 +11,10 @@
1111
public class Exercise01_04 {
1212

1313
public static void main(String[] args) {
14-
int a = 2;
15-
int b = 3;
16-
int c = 4;
17-
18-
for (int i = 0; i < 5; i++) {
19-
if (i > 0) {
20-
System.out.print("\n");
21-
}
22-
for (int j = 0; j < 3; j++) {
23-
24-
if (i == 0) {
25-
if (j == 0)
26-
System.out.print("a ");
27-
if (j == 1)
28-
System.out.print("a^2 ");
29-
if (j == 2)
30-
System.out.print("a^3");
31-
32-
} else if (i == 1) {
33-
System.out.print("1 ");
34-
} else if (i == 2) {
35-
System.out.print(a + " ");
36-
a *= 2;
37-
38-
} else if (i == 3) {
39-
System.out.print(b + " ");
40-
b *= 3;
41-
42-
} else {
43-
System.out.print(c + " ");
44-
c *= 4;
45-
46-
}
47-
48-
49-
}
50-
51-
14+
int num = 4;
15+
for (int row = 1; row <= num; row++) {
16+
System.out.println(row + " " + row * row + " " + row * row * row);
5217
}
53-
5418
}
5519

56-
5720
}

0 commit comments

Comments
 (0)