本文共 939 字,大约阅读时间需要 3 分钟。
不多说
/* * Author : ben */#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;const int MAXN = 90;char graph[MAXN][MAXN];int main() { int n; while (scanf("%d", &n) == 1) { memset(graph, ' ', sizeof(graph)); int w = 2 * n + 1; int in = 2 * n - 3; for (int i = 0; i < w; i++) { graph[i][0] = '*'; graph[i][w - 1] = '*'; graph[i][w] = 0; } for (int j = 0; j < w; j++) { graph[0][j] = '*'; graph[w - 1][j] = '*'; } for (int j = 2; j < w - 2; j++) { graph[2][j] = '*'; graph[w - 3][j] = '*'; } for (int i = 2; i < w - 2; i++) { graph[i][2] = '*'; graph[i][w - 3] = '*'; } for (int i = 0; i < w; i++) { printf("%s\n", graph[i]); } } return 0;}
转载于:https://www.cnblogs.com/moonbay/p/4279610.html