Advertisement
a53

GenMat28

a53
Feb 29th, 2020
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int a[31][31];
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin>>n;
  9. for(int k=1;k<=n;++k)
  10. for(int i=1,j=k;i<=k&&j>=1;++i,--j)
  11. {
  12. if(i+j==k+1)
  13. {
  14. if(k%2)
  15. a[i][j]=a[n-i+1][n-j+1]=(k+1)/2;
  16. else
  17. a[i][j]=a[n-i+1][n-j+1]=(n-k/2+1);
  18. }
  19. }
  20. for(int i=1;i<=n;++i,cout<<'\n')
  21. for(int j=1;j<=n;++j)
  22. cout<<a[i][j]<<' ';
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement