#include
#include
#include
std::vector nums = {1, 3, 5, 7, 9, 5};
立即学习“C++免费学习笔记(深入)”;
auto it = std::find(nums.begin(), nums.end(), 5);
if (it != nums.end()) {
std::cout << "找到元素,位置:" << it - nums.begin() << std::endl;
}
int cnt = std::count(nums.begin(), nums.end(), 5);
std::cout << "数字5出现了 " << cnt << " 次" << std::endl;
std::greater()
std::vector arr = {4, 2, 5, 1};
std::sort(arr.begin(), arr.end()); // 升序
// 结果:{1, 2, 4, 5}
std::sort(arr.begin(), arr.end(), [](int a, int b) {
return a > b;
}); // 降序
std::reverse(arr.begin(), arr.end()); // 反转
go语言参考手册 中文CHM版
Go 是一个开源的编程语言,它能让构造简单、可靠且高效的软件变得容易。本文给大家带来Go参考手册,需要的可以来下载! Go是从2007年末由Robert Griesemer, Rob Pike, Ken Thompson主持开发,后来还加入了Ian Lance Taylor, Russ Cox等人,并最终于2009年11月开源,在2012年早些时候发布了Go 1稳定版本。现在Go的开发已经是完全开放的,并且拥有一个活跃的社区。 Go 语言特色 简洁、快速、安全 并行、有趣、开源 内存管理、v数组安全、编译
下载
std::vector src = {1, 2, 3, 4};
std::vector dst(4);
std::copy(src.begin(), src.end(), dst.begin());
std::transform(src.begin(), src.end(), dst.begin(), [](int x) {
return x * x;
}); // dst 变为 {1, 4, 9, 16}
std::vector a = {1, 2, 3}, b = {2, 3, 4};
std::vector res(6);
auto it = std::merge(a.begin(), a.end(), b.begin(), b.end(), res.begin());
res.resize(it - res.begin()); // 合并后调整大小
