题解 | #字符串分隔# C++
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> using namespace std; int main() { string str; getline(cin, str); int n = str.size(); if (n % 8 < 8) { str.append(string( (8 - n % 8), '0')); } for (int i = 0; i < n; i += 8) { string sub = str.substr(i, 8); cout << sub << endl; } return 0; }