题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    string str;
    string str8="00000000";
    getline(cin,str);
    int len=str.length();
    for(int i=0;i<len;i=i+8){
        if(i+8>len){
            str8=str.substr(i,len-i);
            str8.append(8-(len-i),'0');
        }
        else if(i+8<=len){
            str8=str.substr(i,8);
        }
        cout<<str8<<endl;

    }
        
    return 0;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
小浪_Coding:找硬件测试,也可兼顾软测欧, 简历还可以的 ,注意排版,项目写的有条理一点, 然后个人技能多加点, 润色好简历之后就开始沟通海投了,深圳,东莞这边做硬件相关的公司还不少, 医疗类,仪器类的都可以尝试
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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