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