fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int r;
  7. cin >> r;
  8.  
  9. for(int i = 0; i < r; i++)
  10. {
  11. // print leading spaces
  12. for(int j = 0; j < i; j++)
  13. {
  14. cout << " ";
  15. }
  16.  
  17. // print stars
  18. for(int k = 0; k < 2*(r - i) - 1; k++)
  19. {
  20. cout << "*";
  21. }
  22.  
  23. cout << endl;
  24. }
  25.  
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5292KB
stdin
6
stdout
***********
 *********
  *******
   *****
    ***
     *