题解 | 字符串分隔
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include <string> using namespace std; int main() { string str; while(cin >> str){ int len = str.size(); if( len % 8 != 0){ int count = 8 - len % 8; str.append(count, '0'); } int newlen = str.size(); for(int j = 0 ; j < newlen ; j += 8){ cout << str.substr(j, 8)<<endl; } } return 0; } // 64 位输出请用 printf("%lld")
append 在字符串末尾补上0