用*显示一个菱形

代码
#include<stdio.h>
#include
<math.h>
void main()
{
int n=7;
int o=(n/2);
int t=1;
int step=2;

for(int i=0;i<n;i++)
{
for(int j=0;j<abs(o);j++)
printf(
" ");
o
--;
for(int k=1;k<=t;k++)
printf(
"*");
t
=t+step;
if(t==n)
step
=-step;
printf(
"\n");
}
}
原文地址:https://www.cnblogs.com/qixin622/p/1761697.html