题解 | #反序输出#

反序输出

https://www.nowcoder.com/practice/171278d170c64d998ab342b3b40171bb

之前上机都用C,后来发现C++有很多函数很方便,果断转C++

这个题就用到了reverse翻转函数,只需要指明需要翻转的范围即可。

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

int main() {
    string str;
    while (cin >> str) { // 注意 while 处理多个 case

        reverse(&str[0],&str[4]);
        cout <<str<< endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

不愿透露姓名的神秘牛友
今天 13:47
点赞 评论 收藏
分享
05-24 14:12
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务