1.函数:distance(begin,end); //计算迭代器begin和迭代器end之间的距离;
#include<set>
#include <iostream>
int main()
{
//求s中大于5的数有几个
std::set<int> s; //s={0 1 2 3 4 5 6 7 8 9};
for (int i = 0; i < 10; i++)
{
s.insert(i);
}
std::set<int>::iterator it = s.upper_bound(5);//返回大于5的第一个迭代器
std::cout << distance(it,s.end())<<std::endl;
system("pause");
return 0;
}