SHARE
TWEET

Untitled

a guest Oct 18th, 2019 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin>>n;
  9.     if(n==1) cout<<"*";
  10.     else
  11.     {
  12.     for(int i=1;i<=n;i++)
  13.         if(i==n) cout<<"*";
  14.         else cout<<" ";
  15.     cout<<endl;
  16.     for(int i=2;i<=n-1;i++)
  17.     {
  18.         for(int j=i;j<=n-1;j++)
  19.             cout<<" ";
  20.         cout<<"*";
  21.         for(int j=1;j<=2*(i-1)-1;j++) cout<<" ";
  22.         cout<<"*";
  23.         cout<<endl;
  24.     }
  25.     for(int i=1;i<=2*n;i++)
  26.         if(i%2==1) cout<<"*";
  27.         else cout<<" ";
  28.     }
  29.     return 0;
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top