fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int abs(int a){
  5. if (a < 0)
  6. return -a;
  7. else
  8. return a;
  9.  
  10. }
  11.  
  12. int main()
  13. {
  14.  
  15. const int m=5;
  16. const int n=5;
  17. int k,l;
  18. int A[5][5];
  19.  
  20. cout << "Vvedite stroky k";
  21. k = 4;
  22. cout << "Vvedite stolbec l";
  23. l=2;
  24. cout<<'\n';
  25.  
  26. for(int i=0;i<m;i++)
  27. for(int j=0;j<n;j++){
  28. if (abs(i - k) > abs(j - l))
  29. A[i][j] = abs(i - k) + 1;
  30. else
  31. A[i][j] = abs(j - l) + 1;
  32. }
  33.  
  34.  
  35. for(int i=0;i<m;i++){
  36. for(int j=0;j<n;j++)
  37. cout << A[i][j] << '\t';
  38. cout << '\n';
  39. }
  40. return 0;
  41. }
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
Vvedite stroky kVvedite stolbec l
5	5	5	5	5	
4	4	4	4	4	
3	3	3	3	3	
3	2	2	2	3	
3	2	1	2	3