用*号打印直角三角形(四个方向)
图形一:
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(); } } }