fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8.  
  9. int n,p=-1, i, j;
  10.  
  11. cin>>n;
  12.  
  13. for (i=1;i<=n/2+1;++i) {
  14.  
  15. for (j=1;j<=n/2+1-i;++j){
  16.  
  17. cout<<" ";
  18.  
  19. }
  20.  
  21. cout<<"*";
  22.  
  23. for (j=1;j<=p;++j){
  24.  
  25. cout<<" ";
  26.  
  27. }
  28.  
  29. if (p>0) { cout<<"*";}
  30.  
  31. p+=2;cout<<"\n";
  32.  
  33. }
  34.  
  35. p=n-3;
  36.  
  37. for (i=1; i<=n/2; ++i)
  38.  
  39. {
  40.  
  41. for (j=1; j<=i; ++j)
  42.  
  43. cout << " ";
  44.  
  45. cout << "*";
  46.  
  47. for (j=1;j<p;++j){
  48.  
  49. cout<<" ";
  50.  
  51. }
  52.  
  53. if (p>0) { cout<<"*";}
  54.  
  55. p-=2;cout<<"\n";
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
Success #stdin #stdout 0.01s 5276KB
stdin
7
stdout
   *
  * *
 *   *
*     *
 *   *
  * *
   *