for循环打印菱形

代码
package test;

public class Foryunyong {
public static void main(String[] args) {
int a,b;
int c=5;
for (a = 0; a <= 6; a++) {
for (b=a;b<=c;b++){
System.out.print(' ');
}
for (b=0;b<=a;b++){
System.out.print('*');
System.out.print(' ');
}

        System.out.print("\n");

    }
    int i,j;
    int d=5;
    for (i = 0;i <= 6;i++) {
        for (j=0; j<=i; j++){
            System.out.print(' ');
        }
        for (j=i;j<=d;j++){
            System.out.print('*');
            System.out.print(' ');
        }
        System.out.print("\n");

    }

}



}

posted on 2021-06-08 15:36  三打灭霸哈  阅读(105)  评论(0编辑  收藏  举报