fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void display_rhombus_internal(int size, int width)
  5. {
  6. printf("%*s%*s\n", size + 1, "*", width, "*");
  7. if (size > 0)
  8. {
  9. display_rhombus_internal(size - 1, width + 2);
  10. printf("%*s%*s\n", size + 1, "*", width, "*");
  11. }
  12. }
  13.  
  14. void display_rhombus(int size)
  15. {
  16. printf("%*s\n", size + 1, "*");
  17. if (size > 0)
  18. {
  19. display_rhombus_internal(size - 1, 2);
  20. printf("%*s\n", size + 1, "*");
  21. }
  22. }
  23.  
  24. int main(void)
  25. {
  26. for (int size = 0; size < 5; size++)
  27. {
  28. display_rhombus(size);
  29. }
  30. return 0;
  31. }
Success #stdin #stdout 0s 4692KB
stdin
Standard input is empty
stdout
*
 *
* *
 *
  *
 * *
*   *
 * *
  *
   *
  * *
 *   *
*     *
 *   *
  * *
   *
    *
   * *
  *   *
 *     *
*       *
 *     *
  *   *
   * *
    *