fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. for (int i = 1; i <= 5; i++) {
  6. for (int j = i; j <= 5; j++) {
  7. // Print a star if we are at the first row, the start of the row, or the end of the row.
  8. if (i == 1 || j == i || j == 5) cout << "* ";
  9. else cout << " "; // Print spaces elsewhere
  10. }
  11. cout << endl;
  12. }
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
* * * * * 
*     * 
*   * 
* * 
*