目录
牛客HJ12 字符串反转
解析代码
牛客HJ12 字符串反转
字符串反转_牛客题霸_牛客网
解析代码
#include <iostream>
using namespace std;
int main()
{
string str = "";
cin >> str;
int left = 0, right = str.size() - 1;
while (left < right)
{
char tmp = str[left];
str[left] = str[right];
str[right] = tmp;
++left;
--right;
}
cout << str;
return 0;
}