题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include<stdio.h> #include<string.h> int main() { char str[100] = { 0 }; int n = 0; int a = 0; int count = 0; while (scanf("%s", str) != EOF) { n = strlen(str); if (n % 8 != 0) { a = n % 8; for (int i = n; i < n + (8 - a); i++) { str[i] = '0'; } } for (int j = 0; j < (strlen(str)); j++) { count++; printf("%c", str[j]); if (count % 8 == 0) { printf("\n"); } } } return 0; }