fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. void triangle(ostream& outs, unsigned int m, unsigned int n){
  6. if (m <= n){
  7. for (int i = 0; i < m; i++){
  8. cout<<"*";
  9. }
  10. cout<< endl;
  11. triangle(outs, m+1, n); //getting error here
  12. }
  13. else if (m > n) {
  14. for (int i = 0; i <= n; i++){
  15. cout<<"*";
  16. }
  17. cout<< endl;
  18. if (n) {
  19. triangle(outs, m, n-1);
  20. }
  21. }
  22. }
  23.  
  24. int main() {
  25. triangle(cout, 3, 5);
  26. return 0;
  27. }
Success #stdin #stdout 0s 4508KB
stdin
Standard input is empty
stdout
***
****
*****
******
*****
****
***
**
*