#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main()
{
int line =0 ;//总行数
int column = 0;//总列数
int n = 0;//当前行数
int m = 0;//当前列数
printf("请输入菱形总行数");
scanf("%d", &line);
column = line;
if (line <= 0 || line % 2 == 0)
{
printf("输入错误!");
}
else
{
for (n = 1; n <= line; n++)
{
if (n <= (line / 2) + 1)
{
for (m = 1; m <= column; m++)
{
if ((column + 1) / 2 - (n - 1) <= m&&m <= (column + 1) / 2 + (n - 1))
printf("*");
else
printf(" ");
}
}
else
{
for (m = 1; m <= column; m++)
{
if ((column + 1) / 2 - (line - n) <= m&&m <= (column + 1) / 2 + (line - n))
printf("*");
else
printf(" ");
}
}
printf("\n");
}
}
system("pause");
return 0;
}