题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    string str1;
    while (getline(cin,str1)) 
    { // 注意 while 处理多个 case
        while(str1.size()>8)
        {
            cout<<str1.substr(0,8)<<endl;//截取0-7
            str1 = str1.substr(8,str1.size()-8);
        }    
        int len = str1.size();
        for (int i = len+1;i<=8;i++)
        {
            str1+='0';
        }
        cout<<str1<<endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

牛客773130651号:巨佬,简历模板换成上下的,左右的很烦,hr看着不爽。。。科大随便乱杀,建议能保研就保研,不行也得考一下 ,985硕去干算法,比开发强多了。开发许多双非都能搞,学历优势用不上,算法有门槛
点赞 评论 收藏
分享
求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
一表renzha:你点进去没打招呼他也会有提示的,之前我点进美的,还没打招呼,他马上给我发了不太合适哦
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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