翻转字符串 #include<iostream> #include<string> using namespace std; int main() { string str; cin >> str; for (int i = 0, j = str.size() - 1; i < str.size()/2; i++, j--) { swap(str[i], str[j]); } cout << str; }