fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.  
  9. const size_t n = 6, m = 6;
  10. int a[n+1][m] = { 0 };
  11. int* p = a[1];
  12. for (size_t i = 0; i < n; i++)
  13. {
  14. *p = 1;
  15. p += 2* m * (i & 1);
  16. *(p - 1) = 1;
  17. }
  18. cout << endl;
  19. cout << endl;
  20.  
  21. for (int i = 0; i < n+1; i++)
  22. {
  23. for (int j = 0; j < m; j++)
  24. {
  25. cout << " " << a[i][j];
  26. }
  27. cout << endl;
  28. }
  29. }
  30.  
Success #stdin #stdout 0s 4184KB
stdin
Standard input is empty
stdout

 0 0 0 0 0 1
 1 0 0 0 0 0
 0 0 0 0 0 1
 1 0 0 0 0 0
 0 0 0 0 0 1
 1 0 0 0 0 0
 0 0 0 0 0 1