题解 | #字符串分隔#

字符串分隔

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;      //按每隔八位将字符串输出
    }
}

全部评论

相关推荐

01-30 22:03
门头沟学院 Java
用微笑面对困难:我滴妈,【俩月】【实习】【主管】仨debuff吃满了,独立设计开发的项目写了绝大占比的运营板块,你独立开发,那维护、问题复盘、日志更新、bug、策划书全是自己整的? 不建议写那么大,可以从小出发更容易
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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