题解 | #字符逆序#

字符逆序

http://www.nowcoder.com/practice/cc57022cb4194697ac30bcb566aeb47b

使用reverse()没有意义,这里采用逆向迭代器实现

#include <iostream>
#include <string>
using namespace std;

int main(){
    string s;
    while(getline(cin ,s)){
        for(auto rit = s.rbegin(); rit!=s.rend(); rit++)
            cout << *rit;
        cout << endl;
    }
    return 0;
}
全部评论

相关推荐

1 收藏 评论
分享
牛客网
牛客企业服务