题解 | #字符串分隔#

字符串分隔

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

// #include <iostream>
// #include <string>
// using namespace std;
// int main() {
//     char a;
//     string str={};
//     int count=0;
    
//     do{
//         a = getchar(); // 注意 while 处理多个 case
//         if(count!=8){str.append(a.to_string());count+=1;}
//         else if(count == 8){str.append(count,a);
//         cout<<str<<endl;
//         str.clear();
//         count = 0;}
//     }while(a!='\n');
//     int b = str.size();
//     cout<<str;
//     if(b<8){
//         for(int i = 1;i<=8-b;i++)
//             {
//                 count<<0;
//             }
//     }
// }
#include <iostream>
#include <string>

using namespace std;

int main() {
  string str;
  while (cin >> str) {
    while (str.size() > 8) {
      cout << str.substr(0, 8) << endl;
      str = str.substr(8);
    }
    str.resize(8, '0');
    cout << str << endl;
  }
  return 0;
}

全部评论

相关推荐

只有一个苍穹外卖外加正在看黑马点评,可以找小厂实习吗,还有我的简历有什么大问题吗
Java抽象小篮子:感觉有点熟悉,问题1是学历,2是没实习经历,3是专业技能写得太少太少了(怎么写可以看我置顶帖),4是仅这一个项目找实习不够看。拷打完毕,简历怎么写可以看我置顶帖子
点赞 评论 收藏
分享
自由水:这HR已经很好了,多的是已读不回和不读了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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