标签:lease putchar 语言 ret input turn layer The c语言
输出向下的金字塔
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;
}
标签:lease putchar 语言 ret input turn layer The c语言
原文地址:https://www.cnblogs.com/liujiaxin2018/p/14708025.html