fork(1) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. printStar(17);
  6. return 0;
  7. }
  8.  
  9. void printStar(int width) {
  10. int space = 0, star = width;
  11. for(int i = 0 ; i < width; i++) {
  12. for(int j = 0 ; j < space; j++)
  13. printf(" ");
  14. for(int k = 0 ; k< star; k++)
  15. printf("*");
  16.  
  17. printf("\n");
  18.  
  19. if(i < width/2) {
  20. ++space;
  21. star-=2;
  22. } else {
  23. star+=2;
  24. --space;
  25. }
  26. // printf("%d %d %d", space, star, i);
  27. }
  28. }
Success #stdin #stdout 0s 9424KB
stdin
Standard input is empty
stdout
*****************
 ***************
  *************
   ***********
    *********
     *******
      *****
       ***
        *
       ***
      *****
     *******
    *********
   ***********
  *************
 ***************
*****************