题解 | #字符串分隔#

字符串分隔

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

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



int main()
{
    //变量表
    string data;
    string output;
    int counter;
    //初始化
    getline(cin,data);
    while(data.size()>8)
    {
        cout<<data.substr(0,8)<<endl;
        data=data.substr(8,data.size()-8);
    }
    if(data.size() == 8)
        {
            cout<<data<<endl;
        }
    else
        {
            for(int i=data.size();i<8;i++)
            {
                data+='0';
            }
            cout<<data<<endl;
        }
}
全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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