dimanche 1 novembre 2015

Finding position of an element in vector of vectors

Let A be a vector of vectors of type double, i.e. vector<vector<double> > A and B be the same but for integers, i.e. vector<vector<int> > B. Assume that size of A and B is the same (and sizes of every nested vectors are equal as well).

I would like to check if j is contained in i-th vector of B by using std::find, so I write std::find(B[i].begin(), B[i].end(), j) != B[i].end(). Now, if that is true I would like to return value in A corresponding to [i][position_of_j_found_in_B[i]]. How can I accomplish this?

Aucun commentaire:

Enregistrer un commentaire