题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include <string> using namespace std; int main() { string str; getline(cin, str); int len = str.length(); while (len > 0) { len = str.length(); if (len > 8) { cout << str.substr(0,8) << endl; str = str.substr(8,len-8); } else { for (int j = 0; j < 8-len; j++) { str += "0"; } cout << str << endl; break; } } return 0; }