C语言打印数字图案

来源:百度知道 编辑:UC知道 时间:2024/05/09 15:12:29
编写一个程序,用于生成如图所示的输出结果,要求根据用户输入的一个整数,输出一个数字组成的图案.

请输了一个数:5

55555
4444
333
22
1

1
22
333
444
555
Press any key to continue

#include <stdio.h>
#include <stdlib.h>

main()
{
int a,b,c;
scanf("%d",&c);
for (a=c; a >= 1; a--) {
for (b=1; b <= a; b++) printf("%d",a);
putchar('\n');
}
putchar('\n');
for (a=1; a <= c; a++) {
for (b=1; b <= a;b++) printf("%d",a);
putchar('\n');
}
system("pause");
return 0;
}