读书人

【STL】find示范

发布时间: 2012-12-15 15:16:03 作者: rapoo

【STL】find示例
find声明:

void test_find(){std::list <int> L;std::list <int>::iterator Iter;std::list <int>::iterator result;L.push_back(40);L.push_back(20);L.push_back(10);L.push_back(30);L.push_back(10);std::copy(L.cbegin(), L.cend(), std::ostream_iterator<int>(std::cout, " "));std::cout << std::endl;result = std::find(L.begin(), L.end(), 10);if (result == L.end())std::cout << "There is no 10 in list L.";else {std::cout << "There is a 10 in list L";if (++result != L.end())std::cout << " and it is followed by a " << *result << ".";}std::cout << std::endl;}






读书人网 >编程

热点推荐