题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <cstring>
#include <iostream>
using namespace std;
int main() {
string str;
getline(cin,str);
int N=str.length()/8+1;
for (int i=0; i<str.length(); i=i+8) {
if(i==(N-1)*8){
for (int j=0; j<=7; j++) {
if(j<=str.length()-8*(N-1)-1){
cout<<str[i+j];
}
else{
cout<<'0';
}
}
cout<<endl;
}
else {
for (int j=0; j<=7; j++) {
cout<<str[i+j];
}
cout<<endl;
}
}
}
// 64 位输出请用 printf("%lld")
获取输入,输入分段,遍历时把握最后一段
