C语言实现BC68-X型图案

#define  _CRT_SECURE_NO_WARNINGS 1
#include
int main()
{
//要打印X型图案是吧
//根据题目的要求,我们要打印的是一个n*n的图案,只有两个字符,‘*’和' '。
//通过图案找出规律
int n = 0;
//int y = 0;
while (scanf("%d", &n) != EOF)
{
//行
int i = 0;
for (i = 0; i < n; i++)
{
//列
int j = 0;
for (j = 0; j < n; j++)
{
if (i == j)
{
printf("*");
}
else if (i + j == n-1)
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
return 0;
}

你可能感兴趣的:(C语言题目,c++,c语言)