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

来源:百度知道 编辑:UC知道 时间:2024/06/04 05:43:16
a
a b
a b c
| |
a b c …… x y z
郁闷,这怎么输出啊
就杨辉三角那样的!

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<n;i++)
for(j=0;j<n;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<n;i++)
{for(j=0;j<=i;j++) /*注意{}括的地方,如括下面一行就排列不好哦*/

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