利用数组与循环与if判断编写一个程序,这个程序运行时会显示出一个类似三角形的图案,要求依旧类似写教程(注:三角形用-或者*组合而成就可以了)
//输入几,打印几层
#include<stdio.h>
int main()
{
int a,c=1,i,j,x,n,p = 0;
while( scanf("%d",&a)!=EOF)
{
x = a;
for(i = 1;i <=a ; i++)
{
x=x-1;
for(j = 1;j <= x; j++)
{
printf(" ");
}
j = 1;
for(n = 1;n <= 2 * c - 1; n++)
{
printf("*");
}
c=c+1;
printf("\n");
}
c=1;
}
return 0;
}