fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. vector< vector<int> > a;
  9.  
  10. int n;
  11. cin >> n;
  12.  
  13. a.reserve(n);
  14.  
  15. for(int i = 0; i < n; ++i) a[i].reserve(n);
  16.  
  17. for(int i = 0; i < n; ++i)
  18. for(int j = 0; j < n; ++j) cin >> a[i][j];
  19.  
  20. for(int i = 0; i < n; ++i)
  21. {
  22. for(int j = 0; j < n; ++j) cout << a[i][j] << " ";
  23.  
  24. cout << "\n";
  25. }
  26.  
  27. }
  28.  
  29.  
Success #stdin #stdout 0s 4300KB
stdin
2
1 2 3 4
stdout
1 2 
3 4