fork download
  1. // Cenyao Huang CS1A Homework 2, P. 83, #15
  2.  
  3. /*******************************************************************************************
  4. * DISPLAY PATTERN
  5. * This program will display a triangle pattern with astericks
  6. *
  7. * Input
  8. * row1 : the first row of astericks
  9. * row2 : the second row of astericks
  10. * row3 : the third row of astericks
  11. * row4 : the fourth row of astericks
  12. *
  13. * Output
  14. * a triangle pattern made of astericks
  15. *******************************************************************************************/
  16.  
  17. #include <iostream>
  18. #include <string>
  19. using namespace std;
  20.  
  21. int main() {
  22. string row1 = " * ", row2 = " *** ", row3 = " ***** ", row4 = "*******"; // define variables
  23.  
  24. cout << row1 << endl << row2 << endl; // display triangle pattern
  25. cout << row3 << endl << row4 << endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
   *   
  ***  
 ***** 
*******