题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream> #include <string> using namespace std; int main() { string inp; string res; cin >> inp; int j = 0, i = 0; int n = inp.size(); if (n == 0) return 0; for (; i < n; i++) { if (i != 0 && i % 8 == 0) { cout << '\n'; cout << inp[i]; } else { cout << inp[i]; } } if (n % 8 != 0) { int l = 8 - n % 8; for (int k = 0; k < l; k++) cout << '0'; } } // 64 位输出请用 printf("%lld")#华为OD机试真题#
华为OD机测试题 文章被收录于专栏
个人练习专栏