题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <stdio.h> #include <string.h> int main() { char str[1000]; fgets(str, sizeof(str), stdin); int len = strlen(str) - 1; // 减去末尾的 \n int zeros = len % 8 == 0 ? 0 : 8 - len % 8; for (int i = 0; i < len + zeros; i++) { if (i > 0 && i % 8 == 0) { printf("\n"); } if (i < len) { printf("%c", str[i]); } else { printf("0"); } } // printf("\n"); return 0; }