首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

【STL】find示范

2012-12-15 
【STL】find示例find声明:void test_find(){std::list int Lstd::list int::iterator Iterstd::list

【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;}






热点排行