输出向下的金字塔
1、for语句
#include <stdio.h>
int main(void)
{
int i, j, layer;
puts("please input the layer");
printf("layer = "); scanf("%d", &layer);
for(i = 1; i <= layer; i++)
{
for(j = 1; j <= i - 1; j++)
{
putchar(' ');
}
for(j = 1; j <= (layer -i) * 2 + 1; j++)
{
printf("%d", i%10);
}
putchar('\n');
}
return 0;
}