题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    string s;
    cin >> s;

    //如果字符串不为8的整数倍,可以先补0
    int len = s.size();
    if (len % 8 != 0) {
        int count = 8 - len % 8;
        s.append(count, '0');
    }

    //每隔8个字符打印输出
    int newLen = s.size();
    for(int i = 0; i < newLen; i +=8)
    {
        cout << s.substr(i, 8) << endl;
    }
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

frutiger:逆天,我家就安阳的,这hr咋能说3k的,你送外卖不比这工资高得多?还说大厂来的6k,打发叫花子的呢?这hr是怎么做到说昧良心的话的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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