赛前最后给自己一点建议
作者:互联网
#include <cstdio>
#include <algorithm>
#include <ctime>
#include <set>
using namespace std;
int a[11], b[11], c[11];
int main(){
// 文件对比
/*while (1){
if (system("fc print1.txt print2.txt")) break;
}*/
// 随机数
/*srand(time(0));
int n = rand() % 10000;
printf("%d\n", n);*/
// 读写
/*freopen("csp2021.in", "r", stdin);
freopen("csp2021.out", "w", stdout);*/
// 离散化
/*a[1] = 10, a[2] = 9, a[3] = 15, a[4] = 1, a[5] = 15;
c[1] = 10, c[2] = 9, c[3] = 15, c[4] = 1, a[5] = 15;
sort(a + 1, a + 5 + 1);
int len = unique(a + 1, a + 5 + 1) - a - 1;
for (int i = 1; i <= len; ++i)
b[i] = lower_bound(a + 1, a + len + 1, c[i]) - a;
for (int i = 1; i <= len; ++i)
printf("%d ", b[i]);
// 3 2 4 1 */
// set (不可重复) multiset (可重复)
// 插入 -> insert 删除 -> erase
/*set<int> s1;
// 0 1 2 3 4 5
s1.insert(10), s1.insert(5), s1.insert(77),
s1.insert(7), s1.insert(8), s1.insert(7777777);
s1.erase(5);
printf("%d\n", *s1.find(777));
printf("%d\n", *s1.lower_bound(8));// >= x 的最小的一个
printf("%d\n", *s1.end());
printf("%d\n", *s1.upper_bound(4));// > x 的最小的一个*/
// next_permutation
/*for (int i = 1; i <= 4; ++i) a[i] = i;
do {
for (int i = 1; i <= 4; ++i) printf("%d ", a[i]);
puts("");
} while (next_permutation(a + 1, a + 5));*/
a[1] = 1, a[2] = 3, a[3] = 10, a[4] = 17;
int i = lower_bound(a + 1, a + 5, 15) - a;
printf("%d\n", i);
return 0;
}
标签:insert,建议,include,15,int,s1,printf,一点,赛前 来源: https://www.cnblogs.com/Niuwadiandian/p/15435239.html