fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void)
  5. {
  6. const int N = 4;
  7. for (int i = 0; i <= N*2; i++)
  8. {
  9. int before = abs(N - i);
  10. int width = 2 * (N - before);
  11. if (width > 0)
  12. printf("%*s%*s\n", before + 1, "*", width, "*");
  13. else
  14. printf("%*s\n", before + 1, "*");
  15. }
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
    *
   * *
  *   *
 *     *
*       *
 *     *
  *   *
   * *
    *