C语言编写程序,输出下列图形~请求解答,谢谢

a a b a b c | | a b c …… x y z郁闷,这怎么输出啊就杨辉三角那样的!
2025-02-26 03:58:15
推荐回答(1个)
回答1:

void Main()
{
//第几列
int count=1;
//当小于总列数时循环
while(count<='z'-'a'+1)
{
for(int i='a';i<'a'+count;i++)
printf("%c ",i);
count++;
printf("\n");
}
}

/*下面是C杨辉三角打印程序,他的特点是可以输入要打印的行数,比较灵活*/
#include "stdio.h"

main()
{
int yh[15][15];
int i,j,n;
printf("********************\n*打印杨辉三角数\n********************\n");
printf("请输入打印的行数n,(n<=15):");
scanf("%d",&n);
for(i=0;i for(j=0;j {if(j==0||i==j)
yh[i][j]=1;
else
yh[i][j]=yh[i-1][j-1]+yh[i-1][j];
}
for(i=0;i {for(j=0;j<=i;j++) /*注意{}括的地方,如括下面一行就排列不好哦*/

printf("%5d",yh[i][j]);
printf("\n");
}

getch();
}

/*输入10
enter
结果:
********************
*打印杨辉三角数
********************
请输入打印的行数n,(n<=15):10
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
1 9 36 84 126 126 84 36 9 1

*/