参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int high = scanner.nextInt(); int width = scanner.nextInt(); char c = scanner.next().charAt(0); int cc = scanner.nextInt(); for(int i = 0; i < width; i++) System.out.printf("%c", c); System.out.println(); for(int i = 0; i < high - 2; i++) { for(int j = 0; j < width; j++) { if(j == 0 || j == width - 1) System.out.printf("%c", c); else { if(cc == 0) System.out.print(" "); else System.out.printf("%c", c); } } System.out.println(); } for(int i = 0; i < width; i++) System.out.printf("%c", c); } }
0.0分
5 人评分