fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. cin >> n;
  8. int start = 1;
  9. int space = n-1;
  10. for ( int i =1;i<=n;i+=1)
  11. {
  12. for(int s=1 ;s<=space ; s++)
  13. {
  14. cout << " ";
  15. }
  16. for(int j =1; j<= 2*i-1 ;j++)
  17. {
  18.  
  19. cout << "*" ;
  20. }
  21.  
  22. start+=2;
  23. cout << endl;
  24.  
  25. }
  26.  
  27.  
  28. }
  29.  
  30.  
  31.  
Success #stdin #stdout 0s 5312KB
stdin
4
stdout
   *
   ***
   *****
   *******