国产探花免费观看_亚洲丰满少妇自慰呻吟_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++ 注意點

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

圖片精選

主站蜘蛛池模板: 原平市| 稻城县| 若尔盖县| 得荣县| 西乡县| 阿克苏市| 镇原县| 棋牌| 全州县| 莱西市| 兴宁市| 台北县| 松江区| 镇宁| 康平县| 全南县| 防城港市| 波密县| 平利县| 西充县| 巴青县| 丹棱县| 通河县| 延寿县| 汨罗市| 苍山县| 道孚县| 南城县| 迭部县| 洛阳市| 湾仔区| 民勤县| 江陵县| 石渠县| 贡觉县| 梧州市| 墨江| 新龙县| 富阳市| 天峻县| 武穴市|