我定义了这样一个数组,用reverse会报错,不改变数组定义的方式的情况下,怎么写rever里面的参数才能翻转数组
2条回答 默认 最新
- _GX_ 2022-02-25 14:46关注
逆序输出数组
#include <iostream> #include <algorithm> #include <iterator> using namespace std; int main() { int a[] = {1, 2, 3, 4, 5}; copy(rbegin(a), rend(a), ostream_iterator<int>(cout, " ")); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决评论 打赏 举报无用 2