62,616
社区成员
发帖
与我相关
我的任务
分享
**
* *
* *
* *
**
public class Test {
public static void main(String[] args) {
print(7);
}
public static void print(int line) {
if(line % 2 == 0) {
line++;
}
for(int m = line / 2, i = -m; i <= m; i++) {
for(int n = (line + 1) / 2, k = n - Math.abs(i), j = -n; j <= k; j++) {
if(j == 0) continue;
System.out.print(Math.abs(i) + Math.abs(j) == n ? "*" : " ");
}
System.out.println();
}
}
}
**
* *
* *
* *
* *
* *
**