fork download
  1. #include <algorithm>
  2. #include <vector>
  3. #include <iostream>
  4.  
  5.  
  6. int main()
  7. {
  8. int A = 6;
  9. int l = 2*A - 1;
  10. std::vector< std::vector<int> > ar(l, std::vector<int>(l)); // fixed
  11.  
  12. for(int i = 0; i<(2*A - 1); i++)
  13. {
  14. for (int j = 0; j<(2*A - 1); j++)
  15. {
  16. int h = std::max(abs(A - i + 1),abs(A - j + 1));
  17. ar[i][j] = h+1;
  18. }
  19.  
  20. }
  21. for(const auto& vec: ar)
  22. {
  23. for(const auto& it: vec)
  24. std::cout << it << " ";
  25. std::cout << std::endl;
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 4248KB
stdin
Standard input is empty
stdout
8 8 8 8 8 8 8 8 8 8 8 
8 7 7 7 7 7 7 7 7 7 7 
8 7 6 6 6 6 6 6 6 6 6 
8 7 6 5 5 5 5 5 5 5 5 
8 7 6 5 4 4 4 4 4 4 4 
8 7 6 5 4 3 3 3 3 3 4 
8 7 6 5 4 3 2 2 2 3 4 
8 7 6 5 4 3 2 1 2 3 4 
8 7 6 5 4 3 2 2 2 3 4 
8 7 6 5 4 3 3 3 3 3 4 
8 7 6 5 4 4 4 4 4 4 4