解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class C1788 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { F(sc.nextInt()); } sc.close(); } private static void F(int n){ System.out.println(n); int len = 2*n - 1; char[][] a = new char[len][len]; int min = 0, max = 0; if(n % 2 == 0){ min = n - 2; max = n; }else{ min = n - 1; max = n - 1; } while(min >= 0 && max <= len - 1){ for(int i = min; i <= max; i++){ a[min][i] = '*'; a[max][i] = '*'; a[i][min] = '*'; a[i][max] = '*'; } min -= 2; max += 2; } for(int i = 0; i < len; i++){ for(int j = 0; j < len; j++){ System.out.print(a[i][j] == '*' ? '*' : ' '); } System.out.println(); } } }
0.0分
0 人评分
K-进制数 (C++代码)浏览:858 |
数列 (C++代码)浏览:664 |
字符串输入输出函数 (C++代码)(都当成字符串吧hhhhhhhh)浏览:493 |
C二级辅导-进制转换 (C语言代码)浏览:615 |
蓝桥杯历届试题-九宫重排 (C++代码)浏览:2783 |
【出圈】 (C语言代码)浏览:558 |
兰顿蚂蚁 (C++代码)浏览:1091 |
字符串问题 (C语言代码)浏览:1521 |
C语言程序设计教程(第三版)课后习题1.6 (C++代码)浏览:902 |
C语言训练-列出最简真分数序列* (C语言代码)浏览:619 |