import java.util.Scanner;
public class Ha{
public static void main(String[] args){
System.out.println("请输入圣诞树树身的高度:");
Scanner in = new Scanner(System.in);
int c = in.nextInt();
star(c);
wen(c);
}
public static void star(int han){
for(int i = 0 ;i < han; ++i){
for(int a = han-i; a >= 1; --a){
System.out.print(" ");
}
for(int b = 1; b <= i+1; ++b){
System.out.print("^");
}
System.out.println();
}
}
public static void wen(int han){
if(han % 2 == 0){
for(int b = 0; b<(han -2);b++){
for(int c = 1;c<=(han-2)/2;c++){
System.out.print(" ");
}
System.out.println("@@");
}
}
else{
for(int a=0; a<(han-2);a++){
for(int i = 1; i<=(han-1)/2; i++){
System.out.print(" ");
}
System.out.println("@");
}
}
}
}
使用Java绘制简陋圣诞树
最新推荐文章于 2023-03-21 15:32:16 发布