题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
自测运行有问题,<8的字符串他按不加0处理的,但是提交的话还是可以的
#include <cstring>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;
int main() {
string s;
cin>>s;
int len=s.length();
int add=(len%8==0)?0:(8-len%8);
len+=add;
s.append(add,'0');
for(int i=0;i<len;i++)
{
cout<<s[i];
if((i+1)%8==0&&i<len-1){cout<<'\n';}
}
}
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;
int main() {
string s;
cin>>s;
int len=s.length();
int add=(len%8==0)?0:(8-len%8);
len+=add;
s.append(add,'0');
for(int i=0;i<len;i++)
{
cout<<s[i];
if((i+1)%8==0&&i<len-1){cout<<'\n';}
}
}