SelinD

ex5pg93

May 23rd, 2019
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,i,j,a[25][25];
  6. cin>>n;
  7. for(i=1;i<=n;i++)
  8. {
  9. for(j=1;j<=n;j++)
  10. {
  11. if(i+j<=n+1)
  12. {
  13. a[i][j]=i+j-1;
  14. }
  15. if(i+j>n+1)
  16. {
  17. a[i][j]=a[n+1-j][n+1-i];
  18. }
  19. }
  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. }
Add Comment
Please, Sign In to add comment