c语言输出菱形

#include<stdio.h>

void main()

{

       int i,j,k,a;

       printf("请输入几行菱形:");

       scanf("%d",&k);  

       a=(k+1)/2;   

       for(i=1;i<=a;i++)

       {

              for(j=1;j<=a-i;j++)

              {

                     printf(" ");

              }

              for(j=1;j<=2*i-1;j++)

              {

                     printf("*");

              }

              printf("\n");                      

       }

       for(i=k-a;i>=1;i--)

       {

              for(j=1;j<=a-i;j++)

              {

                     printf(" ");

              }

              for(j=1;j<=2*i-1;j++)

              {

                     printf("*");

              }

              printf("\n");        

       }                                                      

}