Created
February 7, 2025 13:28
-
-
Save OriLiMu/245b260686ee02dcbe9cf410271d93a4 to your computer and use it in GitHub Desktop.
substr,reverse string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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