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