国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > C++ > 正文

C++:distance()

2019-11-06 09:27:43
字體:
來源:轉載
供稿:網友

function template std::distance template typename iterator_traits::difference_type distance (InputIterator first, InputIterator last); Return distance between iterators Calculates the number of elements between first and last.

If it is a random-access iterator, the function uses Operator- to calculate this. Otherwise, the function uses the increase operator (operator++) repeatedly.

Parameters first: Iterator pointing to the initial element. last: Iterator pointing to the final element. This must be reachable from first. InputIterator shall be at least an input iterator.

Return value The number of elements between first and last.

Example // advance example

#include <iostream> // std::cout#include <iterator> // std::distance#include <list> // std::listint main () { std::list<int> mylist; for (int i=0; i<10; i++) mylist.push_back (i*10); std::list<int>::iterator first = mylist.begin(); std::list<int>::iterator last = mylist.end(); std::cout << "The distance is: " << std::distance(first,last) << '/n'; return 0;}

Output:

The distance is: 10


上一篇:c++

下一篇:C++ 注意點

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 南和县| 北宁市| 高州市| 高雄市| 从化市| 双辽市| 安远县| 双牌县| 泰州市| 玛沁县| 沁源县| 句容市| 高平市| 彭阳县| 通山县| 广州市| 永靖县| 元谋县| 鄂州市| 墨竹工卡县| 德格县| 灵宝市| 新乐市| 定陶县| 岫岩| 汤原县| 泸州市| 隆林| 黄骅市| 富锦市| 峨边| 扶沟县| 沛县| 怀安县| 灵寿县| 崇州市| 阜平县| 高碑店市| 方山县| 偃师市| 方山县|