fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. const int size = 9;
  6.  
  7. const int half_size = size / 2;
  8.  
  9. for (int i = 0; i < half_size; i++)
  10. {
  11. for (int j = 0; j < i; j++)
  12. std::cout << " ";
  13. std::cout << "*";
  14. for (int j = 0; j < (half_size - i) * 2; j++)
  15. std::cout << " ";
  16. std::cout << "*\n";
  17. }
  18.  
  19. for (int i = 0; i < half_size; i++)
  20. std::cout << " ";
  21. std::cout << "*\n";
  22.  
  23. for (int i = half_size - 1; i >= 0 ; i--)
  24. {
  25. for (int j = 0; j < i; j++)
  26. std::cout << " ";
  27. std::cout << "*";
  28. for (int j = 0; j < (half_size - i) * 2; j++)
  29. std::cout << " ";
  30. std::cout << "*\n";
  31. }
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
*        *
 *      *
  *    *
   *  *
    *
   *  *
  *    *
 *      *
*        *