stl:reverse

📅 2026/8/25 15:23:52
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}