我有个代码,你看看也许有用哦
#include <stdio.h>
void main()
{
int i,j,n,k;
printf("input n(n<10):");
scanf ("%d",&n);
for (i=1;i<=n;i++)
{
for (j=1;j<=n-i;j++)printf("");
for (j=1;j<=2*i-1;j++)printf("*");
printf("\n");
}
for (i=n-1;i>=1;i--)
{
for (j=1;j<=n-i;j++)printf("");
for (j=1;j<=2*i-1;j++)printf("*");
printf("\n");
}
}