fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int count = 1;
  5. string fact(int num, string o="*"){
  6. if(count == num) return o;
  7. if(num <= 1){
  8. return o;
  9. }else{
  10. string ret;
  11. for(int i=0; i<count+1; i++){
  12. ret += "*";
  13. }
  14. count++;
  15. return fact(num, o + "\n" + ret + "\n" + o);
  16. }
  17. }
  18.  
  19. int main() {
  20. cout << fact(4);
  21. return 0;
  22. }
Success #stdin #stdout 0.02s 2816KB
stdin
Standard input is empty
stdout
*
**
*
***
*
**
*
****
*
**
*
***
*
**
*