标签:ring reverse har log bsp sign sig ret style
思路:在原来的字符串后面添加上strlen-1个字符,返回
class Solution { public: string reverseString(string s) { unsigned int strlen; int i; // char temp; strlen = s.size(); if (strlen > 1) { for (i = strlen - 2; i >= 0 ; i--) { // temp = s[i]; s += s[i]; } return s.substr(strlen - 1 , strlen + strlen - 2); } else return s; } };
标签:ring reverse har log bsp sign sig ret style
原文地址:http://www.cnblogs.com/shawnye/p/5984119.html