fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. cout << "=== Case (A) ===" << endl;
  7. for (int j = 1; j <= 5; j++) {
  8. for (int i = 1; i <= j; i++) {
  9. cout << "*";
  10. }
  11. cout << endl;
  12. }
  13.  
  14. cout << "=== Case (B) ===" << endl;
  15. for (int j = 5; j >= 1; j--) {
  16. for (int i = 1; i <= j; i++) {
  17. cout << "*";
  18. }
  19. cout << endl;
  20. }
  21.  
  22. for (int j = 1; j <= 5; j++) {
  23. for (int i = 1; i <= 6 - j; i++) {
  24. cout << "*";
  25. }
  26. cout << endl;
  27. }
  28.  
  29. cout << "=== Case (C) ===" << endl;
  30.  
  31. // how to print spaces before * ?
  32.  
  33. cout << "=== Case (D) ===" << endl;
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
=== Case (A) ===
*
**
***
****
*****
=== Case (B) ===
*****
****
***
**
*
*****
****
***
**
*
=== Case (C) ===
=== Case (D) ===