题解 | 字符串分隔
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> using namespace std; int main() { string str; cin >> str; int n = str.size(); if (n % 8 != 0) { int add = 8 - n % 8; str.append(add, '0'); //在末尾增加add个0 } for (int i = 0; i < str.size(); i += 8) { string substr = str.substr(i, 8); //从i开始截取8个字符 cout << substr << endl; } } // 64 位输出请用 printf("%lld")