【c语言】数字金字塔

空心的数字金字塔:输入一个正整数n(1<=n<=9),输出n行空心的数字金字塔。要求定义和调用函数hollow_pyramid(n)打印出n行空心的数字金字塔。 (结果如下图所示:)    
      

【c语言】数字金字塔_第1张图片

#include
void hollow_pyramid(int n);
int main()
{
	int n=0;
	printf("input n(1<=n<=9):");
	scanf("%d",&n);
	hollow_pyramid(n);
	return 0;
}
void hollow_pyramid(int n)
{
	int i,j;
enter:if(n<=9){
		for(i=1;i<=n;i++){
			for(j=1;j<=n-i;j++)
				printf(" ");
			for(j=1;j<=i;j++){
				if((j==1||j==i)&&(i

你可能感兴趣的:(c语言,算法,c++)