题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> using namespace std; #include <string> int Max(int a, int b) { if(a>b) { return a; } else { return b; } } int main() { string s; getline(cin, s); if (!s.length()) { return 0; } int smod = s.length() % 8; int schu = s.length() / 8; for(int i =0 ; i< schu; i++ ) { int count = i*8 ; for(int j = 0; j<8; j++) { cout<< s[count+j]; } cout<<endl; } if(smod != 0){ int k; for( k = Max(schu*8,0); k<s.length(); k++) { cout<<s[k]; } for(int m = 0; m<8-smod; m++) { cout<<0; } } } // 64 位输出请用 printf("%lld")