题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include <vector> using namespace std; int main() { string str; int start=0; int tmp=0; vector<string> vec; while(cin>>str) { if(str.empty()) continue; while(start<str.size()){ vec.push_back(str.substr(start,8)); start+=8; } for(int a=0;a<vec.size();a++){ tmp = 8-vec[a].size(); while(tmp--){ vec[a]+='0'; } } for(string it: vec) cout<<it<<endl; } } // 64 位输出请用 printf("%lld")