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