题解 | 字符串分隔
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include <string> using namespace std; int main() { string str; getline(cin, str); int len = str.size(); int index = 0; while(true){ if(len <= 8){ for(int k = index;k <index+len;k++){ cout<<str[k]; } for(int k = 0;k<8-len;k++){ cout<<'0'; } cout<<endl; break; } else{ len-=8; for(int i = index;i<index+8;i++){ cout<<str[i]; } index+=8; cout<<endl; } } } // 64 位输出请用 printf("%lld")