题解 | #X形图案#
X形图案
https://www.nowcoder.com/practice/83d6afe3018e44539c51265165806ee4
#include <stdio.h> int main() { int x = 0; int i = 0; int j = 0; char ch[20][20] = { 0 }; while (scanf("%d", &x) != EOF) { for (i = 0; i < x; i++) { for (j = 0; j < x; j++) { ch[i][j] = ' '; } } for (i = 0; i < x; i++) { ch[i][i] = '*'; ch[i][x - i - 1] = '*'; } for (i = 0; i < x; i++) { for (j = 0; j < x; j++) { printf("%c", ch[i][j]); } printf("\n"); } } return 0; }