fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int m;
  7. cin >> m ;
  8. vector<vector<int>> mat(m,vector<int>(m));
  9. for(int i=0;i<m;i++){
  10. for(int j=0;j<m;j++){
  11. cin >> mat[i][j];
  12. }
  13. }
  14. int r,c;
  15. cin >> r >> c;
  16. //vector<vector<int>> mat(r,vector<int>(c));
  17. for(int i=0;i<m;i++){
  18. for(int j=0;j<m;j++){
  19. if(i<r && j<c)
  20. cout << mat[i][j] << " ";
  21. }
  22. cout << "\n";
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0.01s 5528KB
stdin
4
1 2 3 4
5 6 7 8
9 1 2 3
4 5 6 7
3 2
stdout
1 2 
5 6 
9 1