返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. vector<int> v;
  4. int main()
  5. {
  6.    v.push_back(7);
  7.    v.push_back(3);
  8.    v.push_back(2);
  9.    v.push_back(4);
  10.    v.push_back(11);
  11.    v.push_back(5);
  12.    sort(v.begin(),v.end());
  13.    for(int i:v)
  14.         cout<<i<<" ";
  15.    cout<<endl;
  16.    auto it=lower_bound(v.begin(),v.end(),7);
  17.    cout<<*it<<endl;
  18.    it=upper_bound(v.begin(),v.end(),7);
  19.    cout<<*it<<endl;
  20.    cout<<*(--it)<<endl;
  21.    cout<<*(++it)<<endl;
  22.    cout<<it-v.begin()<<endl;
  23.    it=find(v.begin(),v.end(), 2);
  24.    it=find(v.begin(), v.end(), 12);
  25.    if(it==v.end())
  26.     cout<<"no"<<endl;
  27.    
  28.     return 0;
  29. }
複製代碼

TOP

返回列表