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("@"); } } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)