C++字符串交换字符的位置

RnD*_*RnD 8 c++ string swap

有没有办法在字符串中交换字符位置?例如,如果我有"03/02"我需要"02/03".任何帮助表示赞赏!

Ker*_* SB 25

当然:

#include <string>
#include <algorithm>

std::string s = "03/02";
std::swap(s[1], s[4]);
Run Code Online (Sandbox Code Playgroud)