题解 | #字符串分隔#

字符串分隔

https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7?tpId=37&tqId=21227&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

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

int main() {
    string str;
    getline(cin,str);
    int len =str.length();
    if(len %8 !=0){
        int count =8 -len %8;
        for(int i =0;i <count;i++){
            str +='0';      //先将不足八的倍数的字符串补齐
        }
        len =len +count;
    }
    for(int j=0;j <len;j +=8){
        cout << str.substr(j,8) <<endl;      //按每隔八位将字符串输出
    }
}

全部评论

相关推荐

牛客928043833号:在他心里你已经是他的员工了
点赞 评论 收藏
分享
Rena1ssance_:对的,要是面评没太烂,勤更新简历等捞就行了,腾讯可以无限复活
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务