题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> using namespace std; #include <string.h> int main() { char a[100]; cin >> a; int b = strlen(a); if (b % 8 != 0) { for (int i = b; i < (b + 8 - (b % 8)); i++) { a[i] = '0'; } int c; c = b + 8 - (b % 8); for (int j = 0; j < c; j++) { cout << a[j]; if ((j + 1) % 8 == 0) cout << "\n"; } } else { for (int j = 0; j < b; j++) { cout << a[j]; if ((j + 1) % 8 == 0) cout << "\n"; } } } // 64 位输出请用 printf("%lld")