Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int n,i,j,a[25][25];
- cin>>n;
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- {
- if(i+j<=n+1)
- {
- a[i][j]=i+j-1;
- }
- if(i+j>n+1)
- {
- a[i][j]=a[n+1-j][n+1-i];
- }
- }
- }
- for(i=1;i<=n;i++)
- {
- for(j=1;j<=n;j++)
- cout<<a[i][j]<<" ";
- cout<<endl;
- }
- }
Add Comment
Please, Sign In to add comment