Skip to content

Instantly share code, notes, and snippets.

@OriLiMu
Created February 7, 2025 13:28
Show Gist options
  • Save OriLiMu/245b260686ee02dcbe9cf410271d93a4 to your computer and use it in GitHub Desktop.
Save OriLiMu/245b260686ee02dcbe9cf410271d93a4 to your computer and use it in GitHub Desktop.
substr,reverse string
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
std::string str = "abcd";
// 使用反向迭代器构造反转字符串
reverse(str.begin(), str.begin() + 2);
std::cout << "Reversed string: " << str << std::endl; // 输出 "bacd"
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment