题解 | 合并符串

合并符串

https://www.nowcoder.com/practice/7f436c901a0d450ebdec1168e3e57cc2

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

int main() {
    string s1, s2;
    while (cin >> s1 >> s2) {
        string str;
        for (int i = 0; i < s1.size() / 2; i++) {
            char t = s1[i];
            s1[i] = s1[s1.size() - i - 1];
            s1[s1.size() - i - 1] = t;
        }
        while (s1.size() > 0 && s2.size() > 0) {
            str.push_back(s1.back());
            s1.pop_back();
            str.push_back(s2.back());
            s2.pop_back();
        }
        cout << str << endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
10-01 09:50
门头沟学院 Java
肖先生~:这个人真的很好,点赞
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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