菱形的输出

来源:互联网 发布:wto官网数据库 编辑:程序博客网 时间:2024/05/16 15:09
public class lx {    public static void main(String[] args) {        // TODO Auto-generated method stub        for(int a=1;a<=4;a++)        {          for(int b=1;b<=4-a;b++)                 System.out.print(" ");            for(int c=1;c<=a*2-1;c++)                 System.out.print("*");                System.out.println();        }        for(int d=3;d>=1;d--)        {            for(int b=1;b<=4-d;b++)                System.out.print(" ");            for(int c=4-d;c<=2+d;c++)                 System.out.print("*");                System.out.println();        }    }}

结果如下:
这里写图片描述

原创粉丝点击