题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include<string> using namespace std; int main() { string str; while(getline(cin,str)) { int temp = 0; temp =8 - str.size() % 8; if(temp == 8) temp = 0; for(int i = 0; i < temp; i++) { str += "0"; } int duanshu = str.size() / 8; string ans; for(int i = 0; i < duanshu; i++) { ans = str.substr(8*i,8); cout<<ans<<endl; } } return 0; } // 64 位输出请用 printf("%lld")