题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream>
#include <cstring>
using namespace std;
int main() {
string str;
while (cin>>str){
int count = 0;
int n = str.size();
if (n % 8 != 0)
{
count = 8 - n % 8;
str.append(count,'0');
}
for (int i = 0;i < n + count;i += 8)
{
cout << str.substr(i,8)<<endl;
}
}
return 0;
}
// 64 位输出请用 printf("%lld")
查看12道真题和解析
