// iter/distance.cpp #include #include #include using namespace std; int main() { list coll; // Вставка элементов от -3 до 9 for (int i=-3; i<=9; ++i) { coll.push_back(i); } // Поиск элемента со значением 5 list::iterator pos; pos = find (coll.begin(), coll.end(), // Интервал 5); // Значение if (pos != coll.end()) { // Вычисление и вывод расстояния от начала коллекции cout << "difference between beginning and 5: " << distance(coll.begin(),pos) << endl; } else { cout << "5 not found" << endl; } }