How to get to the Nth element of a 2d std::vector (`std::vector< std::vector<T> >`)?
问题 We are given some int el_position number which is a position of wanted by us element in flatened representation of our 2d vector ( std::vector< std::vector<int> > matrix(5, std::vector<int>(4)) ). Meaning if we had such matrix 11 21 31 41 51 61 71 81 91 101 and we were given el_position == 7 we would need to get second element of second row. Is it possible to do such thing withstd stl 2d vector? How to get value of element by given its position in flattened array? 回答1: Sure this is possible: