题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    string str;
    int start=0;
    int tmp=0;
    vector<string> vec;
    while(cin>>str) {
        if(str.empty())
            continue;
        while(start<str.size()){
            vec.push_back(str.substr(start,8));
            start+=8;
        }
        for(int a=0;a<vec.size();a++){
            tmp = 8-vec[a].size();
            while(tmp--){
                vec[a]+='0';
            }
        }
        for(string it: vec)
            cout<<it<<endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

07-02 22:46
门头沟学院 Java
码农索隆:hr:“管你投没投,先挂了再说”
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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