int main()
{
int i = 0;
int j = 0;
int a = 1;
int tmp = 6;
while (a < 8)//打印前七行
{
for (i = 0;i < 8 - a;i++)
{
printf(" ");//控制空格打印并减少
}
for (i = 1;i <= 2 * a - 1;i++)
{
printf("*");
}
a++;
printf("\n");
}
while (tmp)//打印后六行
{
for (j = 0;j < 8 - tmp;j++)
{
printf(" ");//控制空格打印并增加
}
for (j = 1;j <= 2 * tmp - 1;j++)
{
printf("*");
}
tmp--;
printf("\n");
}
return 0;
}
打印菱形c语言
最新推荐文章于 2024-08-22 17:27:46 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)