C语言实验——for循环打印图形(循环结构)
#include <stdio.h>
int main()
{
int n, i ,temp;
n=4;
for(i=1;i<=n;i++)
{
for(temp = i; temp < n; temp++)
{
printf(" ");
}
for(temp = i; temp > 0; temp--)
{
printf("*");
}
for(temp = i - 1; temp >0; temp--)
{
printf("*");
}
printf("\n");
}
for(i = n - 1; i > 0; i--)
{
for(temp = i; temp < n; temp++)
{
printf(" ");
}
for(temp = i; temp > 0; temp--)
{
printf("*");
}
for(temp = i - 1; temp > 0; temp--)
{
printf("*");
}
printf("\n");
}
return 0;
}