1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
#include <iostream>
#include <string>
using
namespace
std;
void
SetStr(string &str)
{
int
len=str.length();
char
temp;
for
(
int
i=0;i<len/2;i++)
{
//把字符串的两边一一调换
temp=str[i];
str[i]=str[len-1-i];
str[len-1-i]=temp;
}
}
int
main()
{
string a;
cout<<
"input"
<<endl;
cin>>a;
SetStr(a);
cout<<a<<endl;
return
0;
}
|