题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include <cstring> using namespace std; int main() { char s[1000]; cin>>s; int count = strlen(s)/8; int left_value = strlen(s)%8; if (count > 0) { for (int i = 0 ; i < count; i++) { for ( int j = 0; j < 8; j++) { cout<<s[j+i*8]; } cout<<endl; } } if (left_value) { for (int i = 0 ; i < left_value; i++) { cout <<s[i + count *8]; } for (int i = 0; i < 8 -left_value; i++) cout<<0; cout<<endl; } return 0; } // 64 位输出请用 printf("%lld")