循环 实现
/*
*
1
*** 2
*****3
*** 4
*
5
*/
#include <stdio.h>
void main()
{
int i_user=-1;
int i,j,k;
int i_row;
while (i_user<=2)
{
printf("please input a number: ");
scanf(" %d",&i_user);
}
i_row=i_user/2+(i_user%2);
for (i=1;i<=i_row;i++)
{
for (k=1;k<=i_row-i;k++)
printf(" ");
for (j=1;j<=2*i-1;j++)
{
printf("*");
}
printf("\n");
}
for (i=i_row-1;i>=1;i--)
{
for (k=1;k<=i_row-i;k++)
printf(" ");
for (j=1;j<=2*i-1;j++)
{
printf("*");
}
printf("\n");
}
}