Advertisement
Saleh127

CF 1436B

Oct 25th, 2020
60
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. test
  12. {
  13. ll a[105][105]={0},c,d,e,i,j,k,l;
  14. cin>>c;
  15. if(c%2==0)
  16. {
  17. for(i=1; i<=c; i++)
  18. {
  19. a[i][i]=1;
  20. a[i][c-i+1]=1;
  21. }
  22.  
  23. for(i=1; i<=c; i++)
  24. {
  25. for(j=1; j<=c; j++)
  26. {
  27. cout<<a[i][j]<< " ";
  28. }
  29. cout<<endl;
  30. }
  31. }
  32. else if(c%2)
  33. {
  34. for(i=1; i<=c; i++)
  35. {
  36. a[i][i]=1;
  37. a[i][c-i+1]=1;
  38. }
  39. a[c][(c+1)/2]=1;
  40. a[(c+1)/2][1]=1;
  41. for(i=1; i<=c; i++)
  42. {
  43. for(j=1; j<=c; j++)
  44. {
  45. cout<<a[i][j]<< " ";
  46.  
  47. }
  48. cout<<endl;
  49. }
  50. }
  51. }
  52.  
  53.  
  54. return 0;
  55. }
  56.  
Advertisement
RAW Paste Data Copied
Advertisement