题解 | #字符串分隔#

字符串分隔

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

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

int main() {
    string inp;
    string res;
    cin >> inp;
    int j = 0, i = 0;
    int n = inp.size();
    if (n == 0)
        return 0;
    for (; i < n; i++) {
        if (i != 0 && i % 8 == 0) {
            cout << '\n';
            cout << inp[i];
        } else {
            cout << inp[i];
        }
    } 
    if (n % 8 != 0) {
        int l = 8 - n % 8;
        for (int k = 0; k < l; k++)
            cout << '0';
    }
}
// 64 位输出请用 printf("%lld")

#华为OD机试真题#
华为OD机测试题 文章被收录于专栏

个人练习专栏

全部评论

相关推荐

星辰再现:裁员给校招生腾地方
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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