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

OPPO公司福利 1133人发布