1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     string reverseString(string s) 
12     {
13         int len=s.length();
14         int i=0,j=len-1;
15         char temp;
16         while(i<j)
17         {
18             temp=s[j];
19             s[j--]=s[i];
20             s[i++]=temp;
21         }
22         return s;
23     }
24 };

逆置字符串,首末指针,交换指针指向值即可。

posted on 2018-05-25 21:48  高数考了59  阅读(73)  评论(0)    收藏  举报