fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int base = 10;
  5. int height = 8;
  6.  
  7. int main() {
  8. //BUILD TRIANGLE//
  9. string bottom(base, '*');
  10. string top = "*";
  11. int middlerows = height - 1;
  12. int middlespacechars;
  13. cout << top << endl;
  14. for (middlespacechars = 0; middlerows > 1 || middlespacechars < base - 2; ++middlespacechars, --middlerows) {
  15. string middlespace(middlespacechars, ' ');
  16. cout << "*" << middlespace << "*\n";
  17. }
  18. cout << bottom << "\n" << endl;
  19. cout << "^TRIANGLE\n";
  20. cout << "BASE = " << base << endl;
  21. cout << "HEIGHT = " << height << endl;
  22. cout << "goodbye \n" << endl;
  23. return 0;
  24. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
*
**
* *
*  *
*   *
*    *
*     *
*      *
*       *
**********

^TRIANGLE
BASE = 10
HEIGHT = 8
goodbye