十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

stl:reverse

stl:reverse 时间复杂度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}
返回列表