Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- /*int main()
- {
- int a[30][30],n,i,j,m;
- cin>>n>>m;
- for(i=0;i<n;i++)
- for(j=1;j<=m;j++)
- a[0][i]=j;
- for(i=0;i<m;i++)
- for(j=1;j<=n;j++)
- a[i][0]=j;
- for(i=1;i<n-1;i++)
- for(j=1;j<m-1;j++)
- a[i][j]=a[i-1][j-1]++;
- for(i=0;i,n;i++)
- {for(j=0;j<m;j++)
- cout<<a[i][j]<<" ";
- cout<<endl;
- }
- }
- int main()
- {
- int a[30][30],n,i,j;
- cin>>n;
- for(j=0;j<n;j++)
- a[0][j]=j+1;
- for(i=1;i<n;i++)
- a[i][n-1]=n-i;
- for(i=1;i<n;i++)
- for(j=0;j<n-1;j++)
- a[i][j]=a[i-1][j+1];
- for(i=0;i<n;i++)
- {for(j=0;j<n;j++)
- cout<<a[i][j]<<" ";
- cout<<endl;
- }
- }*/
- void citire(int &n)
- {
- cin>>n;
- }
- int main()
- {
- int a[50][50],n,i,K;
- citire(n);
- int s=0,t=n,j,x=1,l;
- if(n%2==0)
- l=n/2;
- if(n%2!=0)
- l=n/2+1;
- for(K=0;K<l;K++)
- {
- for(i=s;i<t;i++)
- {
- a[i][s]=x;
- a[i][t-1]=x;
- }
- for(j=s;j<t;j++)
- {
- a[s][j]=x;
- a[t-1][j]=x;
- }
- s++;
- t--;
- x++;
- }
- for(i=0;i<n;i++)
- {for(j=0;j<n;j++)
- cout<<a[i][j]<<" ";
- cout<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement