Files
python/TangDou/CSP-J/J2-2021/2_Study_STL.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

35 lines
743 B
C++

#include <bits/stdc++.h>
using namespace std;
vector<int> f = {1, 2, 3, 4, 5, 5, 5, 6, 6, 7};
void print() {
for (int i = 0; i < f.size(); i++) printf("%d ", f[i]);
puts("");
}
int main() {
//要使用二分,必须先排序
sort(f.begin(), f.end());
print();
cout << lower_bound(f.begin(), f.end(), 5) - f.begin() << endl;
cout << upper_bound(f.begin(), f.end(), 5) - f.begin() << endl;
//打印
print();
// // 插入值
// int x = 3;
// f.insert(lower_bound(f.begin(), f.end(), x), x);
// //打印
// print();
// // 删除值
// x = 2
// f.erase(lower_bound(f.begin(), f.end(), x));
// //打印
// print();
return 0;
}