缘由https://bbs.csdn.net/topics/397090550
这个算法就不会越界,其关键在于-1之妙。string aa = "123456789"; int a = aa.size(), x = 0;while (a)cout << aa[a-1] << endl,--a;while (x < a)cout << aa[x] << endl,++x;
void reverStr(const string &str)
{size_t len = str.size(), x = 0;while(len)cout << str.at(len-1),--len;while(x < len)cout << str.at(x),++x;cout << endl;
}