SHARE
TWEET

ex9

SelinD May 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,i,j,a[25][25],sus=1,stanga=1,jos,dreapta,k=1;
  6.     cin>>n;
  7.     jos=n;
  8.     dreapta=n;
  9.     while(stanga<dreapta)
  10.     {
  11.         for(j=stanga; j<=dreapta; j++)  { a[sus][j]=k; }
  12.         sus++;
  13.         for(i=sus; i<=jos; i++) {a[i][dreapta]=k;}
  14.         dreapta--;
  15.         for(j=dreapta; j>=stanga; j--) {a[jos][j]=k;}
  16.         jos--;
  17.         for(i=jos; i>=sus; i--) {a[i][stanga]=k;}
  18.         stanga++;
  19.         k=!k;
  20.     }
  21.     for(i=1; i<=n; i++)
  22.     {
  23.         for(j=1; j<=n; j++)
  24.             cout<<a[i][j]<<" ";
  25.         cout<<endl;
  26.     }
  27. }
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
 
Top