- /**
- * 空心菱形
- * @author Zhu_zjiang
- *
- */
- public class Test
- {
- public static void main(String[] args)
- {
- //1,下,打印空格
- for (int x = 0; x<8 ;x++) {
- for (int y = x; y<8 ;y++){
- System.out.print(" ");
- }
- //2,打印一行
- System.out.print("*");
- //3,打印空格
- for (int y = 0; y<x*2 ;y++){
- System.out.print(" ");
- }
- //4,打印一列
- System.out.print("*");
- System.out.println();
- }
- for (int x = 0; x<=8 ; x++) {
- //5,打印向上的空格
- for(int y = 0; y<x ; y++) {
- System.out.print(" ");
- }
- //打印一列
- System.out.print("*");
- //换行
- for(int z = x ; z<8 ; z++ ){
- System.out.print(" ");
- }
- //打印"*"
- System.out.print("*");
- System.out.println();
- }
- }
- }
复制代码 |