fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m, coordA, coordB;
  6. cin >> n >> m >> coordA >> coordB;
  7. int firstVal = (coordA - 1) + (coordB - 1);
  8. for (int i = 1; i <= n; ++i) {
  9. for (int j = 1; j <= m; ++j) {
  10. if (j < m) {
  11. cout << firstVal <<" ";
  12. --firstVal;
  13. } else {
  14. ++firstVal;
  15. cout << firstVal <<" ";
  16. }
  17. }
  18. cout << "\n";
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5272KB
stdin
6 7 
5 2 
stdout
5 4 3 2 1 0 0 
0 -1 -2 -3 -4 -5 -5 
-5 -6 -7 -8 -9 -10 -10 
-10 -11 -12 -13 -14 -15 -15 
-15 -16 -17 -18 -19 -20 -20 
-20 -21 -22 -23 -24 -25 -25