题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main() {
// int a, b;
// while (cin >> a >> b) { // 注意 while 处理多个 case
// cout << a + b << endl;
// }
string d;
getline(cin, d);
int n = d.size();
int outl = ceil(n/8.); // 输出字符串行数
for(int k=0; k<outl; ++k)
{
for(int i=0; i<8; ++i)
{
int tind = k*8+i;
char ch;
if(tind>=n)
{
ch = '0';
}
else
{
ch = d[tind];
}
cout<<ch;
}
cout<<endl; // 行尾换行
}
}
// 64 位输出请用 printf("%lld")