import java.util.Scanner; public class 菱形 { public static void main(String[] args) { Scanner is_scanner = new Scanner(System.in); int hangshu = is_scanner.nextInt(); for (int m = 1; m <= hangshu; m++) { for (int i = 1; i <= hangshu - m; i++) { System.out.print(" "); } for (int s = 1; s <= 2 * m - 1; s++) { if (s == 1 || s == 2 * m - 1 ) { System.out.print("*"); } else { System.out.print(" "); }} System.out.println(); } for (int c = hangshu; c >= 1; c--) { for (int e = 1; e <= hangshu - c; e++) { System.out.print(" "); } for (int d = 1; d <= 2 * c - 1; d++) { if(d==1||d==(2*c-1)){ System.out.print("*");} else{ System.out.print(" ");} } System.out.println(); } }}
07-16
3767
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-30
3378
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
04-09
1320
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-28
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交