fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, i, j;
  6. cin >> n;
  7. int a[n][n]={};
  8.  
  9. for (i=0; i<n/2; i++){
  10. for (j=n/2; j<n; j++) a[i][j]=1;
  11. }
  12. for (; i<n; i++){
  13. for (j=0; j<n/2; j++) a[i][j]=1;
  14. }
  15. for (i=0; i<n; i++){
  16. for (j=0; j<n; j++) cout << a[i][j];
  17. cout << '\n';
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5292KB
stdin
4
stdout
0011
0011
1100
1100