import java.util.Scanner;
class DemoSanJiaoXing{
public static void main(String[] args){
Scanner Input=new Scanner(System.in);
System.out.println("请指定你想要的三角形的规格大小!");
int num=Input.nextInt();
System.out.println("============指定规格的三角形如下所示==========");
for(int i=1; i<=num; i++){
for(int j=num; j>i;j--){
System.out.print(" ");
}
for(int k=1;k<=i;k++){
if(k!=i&k!=1){
System.out.print(" "+" ");
}else
System.out.print("*"+" ");
}
System.out.println();
}
for(int i=1; i<=num-1; i++){
for(int j=1;j<=i;j++){
System.out.print(" ");
}
for(int k=num-i; k>=1; k--){
if(k!=(num-i)&k!=1){
System.out.print(" "+" ");
}else
System.out.print("*"+" ");
}
System.out.println();
}
}
} |
|