C++ 思路简单,答案也简单

字符串分隔

http://www.nowcoder.com/questionTerminal/d9162298cb5a437aad722fccccaae8a7

#include<iostream>
using namespace std;
int main(){
    string a;
    bool b=false;
    while(b||getline(cin,a)){
        b=false;
        if(a.size()==8){
            cout<<a<<endl;
        }
        else if(a.size()<8){
            int dist=8-a.size();
            string tmp(dist,'0');
            cout<<a<<tmp<<endl;
        }
        else{
            cout<<a.substr(0,8)<<endl;
            a=a.substr(8);
            b=true;
        }
    }
    return 0;
}
全部评论
为什么在控制台不输入直接回车无法退出而且会输出00000000呢?
点赞 回复 分享
发布于 2021-09-15 11:33

相关推荐

北漂的牛马人:211佬,包进的,可能是系统问题
点赞 评论 收藏
分享
喜欢喜欢喜欢:这是我见过最长最臭的简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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