题目:反转字符串
void reverse(string& s)
{
int len = s.size();
int begin = 0;//控制前端
int end = len - 1;//控制尾端
while (begin < end)
{
char tmp = s[begin];
s[begin] = s[end];
s[end] = tmp;
begin++;
end--;
}
}
题目:反转字符串
void reverse(string& s)
{
int len = s.size();
int begin = 0;//控制前端
int end = len - 1;//控制尾端
while (begin < end)
{
char tmp = s[begin];
s[begin] = s[end];
s[end] = tmp;
begin++;
end--;
}
}