C++ STL reverse_copy 用法

一:功能

将一个容器元素逆序拷贝到另一个容器中。

二:用法

cpp 复制代码
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    std::vector<int> data{1, 2, 3, 4, 5, 6, 7, 8, 9};
    std::vector<int> out;

    std::ranges::reverse_copy(data, std::back_inserter(out));
    for (auto v : out)
        std::cout << v << " ";
    std::cout << "\n";
}
相关推荐
橘颂TA7 分钟前
【剑斩OFFER】算法的暴力美学——力扣 1020 题:飞地的数量
数据结构·c++·算法·leetcode·职场和发展·结构与算法
乐观勇敢坚强的老彭13 分钟前
c++信奥寒假营集训01
android·java·c++
mango_mangojuice13 分钟前
C++ 学习笔记(string类)
开发语言·c++·笔记·学习
hetao173383713 分钟前
2026-01-27~28 hetao1733837 的刷题记录
c++·笔记·算法
2301_8223663516 分钟前
C++中的智能指针详解
开发语言·c++·算法
kdniao120 分钟前
PHP 页面中如何实现根据快递单号查询物流轨迹?对接快递鸟在途监控 API 实操
android·开发语言·php
郑州光合科技余经理20 分钟前
同城配送调度系统实战:JAVA微服务
java·开发语言·前端·后端·微服务·中间件·php
leaves falling22 分钟前
c语言-函数讲解
c语言·开发语言
癫狂的兔子24 分钟前
【BUG】【Python】【Spider】Compound class names are not allowed.
开发语言·python·bug
css趣多多29 分钟前
动态路由,路由重置,常量路由,$ref,表单验证流程
开发语言·javascript·ecmascript