一、题目
二、代码
class Solution {
public:
void reverseString(vector<char>& s) {
//方法一:手写
int left;
int right;
char temp;
int size_of_s=s.size();
std::cout<<"size_of_s " <<size_of_s<<std::endl;
int i;
left=0;
right=size_of_s-1;
for(i=0;i<size_of_s;i++)
{
std::cout<<" " <<s[i];
}
std::cout<<std::endl;
while(left<right)
{
temp=s[left];
s[left]=s[right];
s[right]=temp;
left++;
right--;
}
for(i=0;i<size_of_s;i++)
{
std::cout<<" " <<s[i];
}
std::cout<<std::endl;
//方法二:STL
// reverse(s.begin(),s.end());
}
};