用*号打印直角三角形(四个方向)

 图形一:

package com.Summer_0416.cn;

/**
 * @author Summer
 * 
 */
public class Test_Method02 {

    public static void main(String[] args) {
        for (int line = 0; line < 5; line++) {
            for (int space = 0; space < (5-1-line); space++) {
                System.out.print(" ");
            }
            for (int star = 0; star < (line+1); star++) {
                System.out.print("*");
            }
            System.out.println();
        }
        

    }

}

图形二:

package com.Summer_0416.cn;

public class Test_Method05 {

    public static void main(String[] args) {
        for (int line = 0; line < 5; line++) {
            for (int space = 0; space < (line+1); space++) {
                System.out.print("*");
            }
            for (int star = 0; star < (5-1-line); star++) {
                System.out.print(" ");
            }
            System.out.println();
        }

    }

}

图形三:

package com.Summer_0416.cn;

public class Test_Method07 {

    public static void main(String[] args) {
        for (int line = 0; line < 5; line++) {
            for (int star = 0; star < (line); star++) {
                System.out.print(" ");
            }
            for (int space = 0; space < (5-line); space++) {
                System.out.print("*");
            }
            System.out.println();
        }


    }

}

图形四:

package com.Summer_0416.cn;

public class Test_Method06 {

    public static void main(String[] args) {
        for (int line = 0; line < 5; line++) {
            for (int space = 0; space < (5-line); space++) {
                System.out.print("*");
            }
            for (int star = 0; star < (line+1); star++) {
                System.out.print(" ");
            }
            System.out.println();
        }

    }

}

 

猜你喜欢

转载自www.cnblogs.com/summerdata/p/10720083.html
0条评论
添加一条新回复