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

TOP

返回列表