调用函数pyramid(n)输出n行数字金字塔
#include<stdio.h>intmain(void){intn;intrepeat,ri;voidpyramid(intn);scanf("%d",&repeat...
#include <stdio.h>
int main(void)
{
int n;
int repeat, ri;
void pyramid(int n);
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%d", &n);
pyramid(n);
}
return 0;
}
void pyramid(int n)
{
int i,j;
for(i=1;1<=n;i++){
for(j=1;j<=n-i;j++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",i);
printf("\n");
}
}
就是照书上抄的,可是始终死循环,求破! 展开
int main(void)
{
int n;
int repeat, ri;
void pyramid(int n);
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%d", &n);
pyramid(n);
}
return 0;
}
void pyramid(int n)
{
int i,j;
for(i=1;1<=n;i++){
for(j=1;j<=n-i;j++)
printf(" ");
for(j=1;j<=i;j++)
printf("%d",i);
printf("\n");
}
}
就是照书上抄的,可是始终死循环,求破! 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询