As a beginner i am exploring multiple methods to increase my clarity, so i did this question.
// no problem with this looping method
vector <vector<int>> vec(n,vector<int>(m));
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> vec[i][j];
}
}
// but i tried in this way using ranged based loop, and it doesn't work.
// I think i need a few modification here, so i need your help.
for(vector<int> v1d : vec){
for(int x : v1d){
cin >> x;
}
}
Same code, just cin replaced by cout, i can print that vector elements easily. but in case of cin i am having problem. no error, but it's not working.
Thanks