fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. void pd(int n){
  6. int i,j,sp=n-1;
  7. for(i=0;i<n;i++){
  8. for(j=0;j<sp;j++)
  9. cout<<" ";
  10. for(j=0;j<i+1;j++)
  11. cout<<"* ";
  12. cout<<"\n";
  13. sp--;
  14. }
  15. sp=0;
  16. for(i=n;i>=0;i--){
  17. for(j=0;j<sp;j++)
  18. cout<<" ";
  19. for(j=0;j<i;j++)
  20. cout<<"* ";
  21. cout<<"\n";
  22. sp++;
  23. }
  24.  
  25. }
  26. int main(int argc, char const *argv[])
  27. {
  28. int n;
  29. cin>>n;
  30. pd(n);
  31. return 0;
  32. }
Success #stdin #stdout 0s 16064KB
stdin
5
stdout
    * 
   * * 
  * * * 
 * * * * 
* * * * * 
* * * * * 
 * * * * 
  * * * 
   * * 
    *