题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    string s;
    getline(cin,s);
    int len=s.length();
    string s1;
    
    for(int i=0;i<len;){
        s1="";
        if(len-i>=8){
            for(int j=0;j<8;j++)s1+=s[i++];
            cout<<s1<<endl;
        }else{
            int len1=len-i;
            for(int j=0;j<len1;j++)s1+=s[i++];
            for(int j=0;j<8-len1;j++)s1+="0";
            cout<<s1<<endl;
        }
    }

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

全部评论

相关推荐

萧索X:写篮球联赛干嘛,陪老板打篮球吗。还有实习经历要写自己所在岗位具体完成什么工作,自己的任务具体完成了什么需求,给公司带来了哪些量化增长
点赞 评论 收藏
分享
01-30 16:13
浙江大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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