题解 | #字符串反转#
字符串反转
http://www.nowcoder.com/practice/e45e078701ab4e4cb49393ae30f1bb04
数据结构用字符串,算法很简单,逆序遍历输出完事了
#include <iostream>
#include <string>
using namespace std;
int main(){
string str, res;
int len;
while(cin >> str){
len = str.size();
for(int i = len-1; i >=0; i--){
res.push_back(str[i]);
}
cout << res << endl;
}
return 0;
}