fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m;
  6. cin >> n >> m;
  7.  
  8. for(int i=0; i<n; i++){
  9. for(int j=0; j<m; j++){
  10. cout << i*m+j+1 << " ";
  11. }
  12. cout << endl;
  13. }
  14. return 0;
  15. }
Success #stdin #stdout 0s 5268KB
stdin
2 3
stdout
1 2 3 
4 5 6