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