题解 | 字符串分隔

字符串分隔

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

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

int main() {
    string str;
    getline(cin, str);
    int len = str.size();
    int index = 0;
    while(true){
        if(len <= 8){
            for(int k = index;k <index+len;k++){
                cout<<str[k];
            }
            for(int k = 0;k<8-len;k++){
                cout<<'0';
            }
            cout<<endl;
            break;
        }
        else{
            len-=8;
            for(int i = index;i<index+8;i++){
                cout<<str[i];
            }
            index+=8;
            cout<<endl;
        }
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

昨天 14:37
门头沟学院 Java
点赞 评论 收藏
分享
给我发了笔试链接,想着等晚上回去做,结果还没做流程就终止了
伟大的小黄鸭在学习:我猜就是笔试几乎没用,就是用来给用人部门拖时间复筛简历的,可能用人部门筛到你简历觉得不合适就提前挂了
投递小鹏汽车等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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