Dec 9, 2010 at 1:53am UTC
Hey,
If I have :
vector < vector<int > > temp;
And I want to access the first integer of the first vector inside temp, how would I code that up ?
Given that both the first vector and integer do exist.
temp[0][0];
does not seem to work...
Cheers,
Last edited on Dec 9, 2010 at 1:54am UTC
Dec 9, 2010 at 2:00am UTC
Could we see the whole code you were using, because maybe the problem is that temp[0][0] wasn't defined... what did you do to get an integer value into that position?
-Albatross
Dec 9, 2010 at 2:07am UTC
So, that is the correct way of accessing that integer ?
1 2 3 4 5
for (int i=0; i<temp.size(); i++) {
for (int j=0; i<temp[i].size(); j++) {
first[i].push_back(temp[i][temp[i].size()-j]);
}
}
I'm positive there is an integer to get from there. Although I can post the full code if this still does not find the culprit.
Last edited on Dec 9, 2010 at 2:08am UTC
Dec 9, 2010 at 2:13am UTC
Careful @Line 2. There's an i where there should be a j, no?
And Line 3... what the heck are you trying to do there?
-Albatross
Dec 9, 2010 at 2:26am UTC
I have :
vector < vector<int> > temp
temp[0] = {1,2,3}
temp[1]= {4,5,6}
and
vector < vector<int> > first
What I want to do is inverse the order of the integers from the vectors in temp. Thus in the end I want to have :
first[0]={3,2,1}
first[1]={6,5,4}
To do this I thought of accessing the last integer of the first vector of temp and push_back the first vector of first.