其他分享
首页 > 其他分享> > 字符串逆置

字符串逆置

作者:互联网

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void reverseString(string &s)
{
int i, j;
for (i = 0, j = s.size() - 1; i < j; ++i, --j)
{
swap(s[i], s[j]);
}
}

int main()
{
string str;
while(cin>>str) {

reverseString(str);
cout << str;
system("pause");
}
return 0;
}

标签:string,int,reverseString,str,字符串,include,逆置,cout
来源: https://www.cnblogs.com/q1231/p/15950391.html