4.用字符*输出三角形
如用字符*输出以下图案:
*
**
***
*****
******
这个我写了两种方法,很简单的菜菜写法,稍微难点的我也不会
代码如下:
第一种(超简单的一种):
#include <stdio.h>
int main()
{
printf("*\n");
printf("**\n");
printf("***\n");
printf("****\n");
printf("*****\n");
}
第二种(内外循环):
#include <stdio.h>
int main()
{
int i,j;
for (i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
putchar('*');
printf("\n");
}
}
结果截图:
11.08练习!!!