fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n = 10;
  7. for (int i = 0; i < n; i++)
  8. {
  9. for (int j = 0; j < n; j++)
  10. {
  11. std::cout << (i + j) % 5 + 1 << " ";
  12. }
  13. std::cout << std::endl;
  14. }
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
1 2 3 4 5 1 2 3 4 5 
2 3 4 5 1 2 3 4 5 1 
3 4 5 1 2 3 4 5 1 2 
4 5 1 2 3 4 5 1 2 3 
5 1 2 3 4 5 1 2 3 4 
1 2 3 4 5 1 2 3 4 5 
2 3 4 5 1 2 3 4 5 1 
3 4 5 1 2 3 4 5 1 2 
4 5 1 2 3 4 5 1 2 3 
5 1 2 3 4 5 1 2 3 4