【STL】find樣本

來源:互聯網
上載者:User

find聲明:

template<class InputIterator, class Type>   InputIterator find(      InputIterator _First,       InputIterator _Last,       const Type& _Val   );

樣本:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.