-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice19.java
More file actions
37 lines (35 loc) · 812 Bytes
/
Copy pathPractice19.java
File metadata and controls
37 lines (35 loc) · 812 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
package fiftypratice;
/**
* 题目:打印出如下图案(菱形)
*
***
*****
*******
*****
***
*
*
* */
public class Practice19 {
public static void main(String[] args) {
int H=7,W=7;
for(int i=0; i<(H+1) / 2; i++) {
for(int j=0; j<W/2-i; j++) {
System.out.print(" ");
}
for(int k=1; k<(i+1)*2; k++) {
System.out.print('*');
}
System.out.println();
}
for(int i=1; i<=H/2; i++) {
for(int j=1; j<=i; j++) {
System.out.print(" ");
}
for(int k=1; k<=W-2*i; k++) {
System.out.print('*');
}
System.out.println();
}
}
}