-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTriangle.java
40 lines (35 loc) · 1.16 KB
/
Triangle.java
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
/**
* Created by Administrator on 2017/6/1.
* Creating a isosceles triangle with number
*/
public class Triangle {
public void isoscelesTriangle() {
for (int i = 1; i < 10; i++) {
for (int j = 9; j > i; j--) {
System.out.print(" ");//for empty space in front of number which make
}
for (int k = i; k >= 1; k--) {
System.out.print(k);//numbers before 1
}
for (int l = 2; l <= i; l++) {
System.out.print(l);//numbers after 1
}
System.out.println("");
}
System.out.println("");
}
public void asteriskTriangle() {
for (int i = 1; i < 10; i++) {
for (int j = 9; j > i; j--) {
System.out.print(" ");//for empty space in front of number which make
}
for (int k = i; k >= 1; k--) {
System.out.print("*");//numbers before 1
}
for (int l = 2; l <= i; l++) {
System.out.print("*");//numbers after 1
}
System.out.println("");
}
}
}