SelinD

v72s2e5

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