Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a[31][31];
- int main()
- {
- int n;
- cin>>n;
- for(int k=1;k<=n;++k)
- for(int i=1,j=k;i<=k&&j>=1;++i,--j)
- {
- if(i+j==k+1)
- {
- if(k%2)
- a[i][j]=a[n-i+1][n-j+1]=(k+1)/2;
- else
- a[i][j]=a[n-i+1][n-j+1]=(n-k/2+1);
- }
- }
- for(int i=1;i<=n;++i,cout<<'\n')
- for(int j=1;j<=n;++j)
- cout<<a[i][j]<<' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement