用星星画菱形 public class Hello{ public static void main(String[] args) { char star = '\u2605'; System.out.println("Hello " + star + " World!"); // output a diamond shape with stars int temp1 = 0, temp2 = 0; for(int i=1; i<=4; ++i){ temp1
方法一 n = int(input('请输入:')) for i in range(1, n, 2): print(('*'*i).center(n)) for i in reversed(range(1, n-1, 2)): print(('*'*i).center(n)) 方法二 n = int(input('请输入:')) i = 1 while i <= n: print((n-i)*' '+'* '*i) i += 1 while n < i < 2*n: print((i-n