题解 | #字符串分隔#

字符串分隔

https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7

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

int main() {
    vector<string> v;
    string s;
    int index = 0;
    while (cin >> s) {
        v.push_back(s);
    }
    for (auto s : v) {
        string temp;
        for (int i = 0; i < s.size(); i++) {
            temp += s[i];
            index++;
            if (index == 8) {
                index = 0;
                cout << temp <<endl;
                temp.clear();
            }

        }
        if (index != 0) {
            for (; index <= 7; index++) {
                temp += '0';
            }
            cout << temp << endl;
            index = 0;
        }

    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

05-12 17:28
已编辑
门头沟学院 硬件开发
ldf李鑫:不说公司名祝你以后天天遇到这样的公司
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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