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