题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> using namespace std; int main() { string str; cin >> str; if(str.size() == 0){ cout << "" << endl; return 0; } int times = 0; string cur_str = ""; for(char c:str){ times ++; cur_str += c; if(times == 8){ cout<< cur_str <<endl; cur_str = ""; times = 0; } } if(cur_str.size()<8 && cur_str!=""){ for(int i=8-cur_str.size();i>0;i--){ cur_str += '0'; } cout<< cur_str <<endl; } } // 64 位输出请用 printf("%lld")