package pra;
public class Triangle {
public static void main(String[] args) {
// 1
for (int i = 1; i < 11; i++) {
for (int j = 11 - i; j > 0; j--) {
System.out.print("*");
}
System.out.println();
}
System.out.println();
// 2
for (int i = 1; i < 11; i++) {
for (int j = 1; j < i+1; j++) {
System.out.print("*");
}
System.out.println();
}
System.out.println();
// 3
for (int i = 1; i < 11; i++) {
for (int j = 0; j < i - 1; j++) {
System.out.print(" ");
}
for (int k = 11 - i; k > 0; k--) {
System.out.print("*");
}
System.out.println();
}
System.out.println();
// 4
for (int i = 1; i < 11; i++) {
for (int j = 1; j < 11 - i; j++) {
System.out.print(" ");
}
for (int k = 1; k < i + 1; k++) {
System.out.print("*");
}
System.out.println();
}
}
}
******星号三角形
最新推荐文章于 2024-11-05 19:36:08 发布