题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream>
using namespace std;
int main() {
string str;
getline(cin, str);
int pad = (8 - str.size() % 8) % 8; //核心代码
str.append(pad, '0'); //后面追加给0,就完事了
int b = 0;
for (auto s : str) {
cout << s;b++;
if ( b % 8 == 0) cout << endl;
}
return 0;
}
文远知行公司福利 603人发布