输入n,打印u
package com.jhliu20.real; import java.util.Scanner; public class XieChengTest { public static void main(String[] args) { int n; Scanner sc = new Scanner(System.in); n = sc.nextInt(); int height = n * 4; char[][] arr = new char[height][height]; for(int i = 0; i < height - n; i++) { for(int j = 0; j < n; j++) { arr[i][j] = '*'; } for(int j = height - 1, k = 0; k < n; j--) { arr[i][j] = '*'; k++; } } int f = 1; for(int i = height - n, count = n; i <= height - 1; i++) { for(int j = f; j < f + n; j++) { arr[i][j] = '*'; } for(int j = height - 1; j > (height) / 2 - 1; j--) { arr[i][j] = arr[i][height - j - 1]; } f++; } for(int i = 0; i < height; i++) { for(int j= 0; j < height; j++) { System.out.print(arr[i][j] == '*' ? '*' : '.'); } System.out.println(""); } } }