fork download
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a,b,i,c;
  5. printf("请输入需要的金字塔层数:");
  6. scanf("%d",&c);
  7. for(i=0;i<=c;i++)
  8. {
  9. if(i%2==0)
  10. continue;
  11. else
  12. b=i;
  13.  
  14. for(c=0;c<=(69-i)/2;c++)
  15. printf(" ",c);
  16. for(a=1;a<=b;a++)
  17. printf("*",a);
  18. printf("\n");
  19. }
  20. }
Success #stdin #stdout 0s 9432KB
stdin
Standard input is empty
stdout
请输入需要的金字塔层数: