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