资讯动态

stl:reverse

发布时间:2026/8/25 15:23:47 来源:尧图企业网站定制
时间复杂度on空间复杂度o1vectorinta/string a; reverse(a.begin(),a.end());vectorvectorinta上下翻转翻转行cppvectorvectorint a {{1, 2, 3},{4, 5, 6},{7, 8, 9}};reverse(a.begin(), a.end());// 结果:// {7, 8, 9}// {4, 5, 6}// {1, 2, 3}左右翻转翻转每行的列cppfor (auto row : a) {reverse(row.begin(), row.end());}// 结果:// {3, 2, 1}// {6, 5, 4}// {9, 8, 7}

读完文章,也想定制专属网站?

尧图设计师 24 小时内与您沟通定制方案

免费获取报价