题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
int main() { char ch[101] = { 0 }; gets(ch);//abcdefgh abc int len = strlen(ch);//11 int full = len / 8;//1 int nofull = len % 8;//3 int count = 0; int i; for (i = 0; i < full*8; i++) { printf("%c", ch[i]); count++; if (count % 8 == 0) { printf("\n"); } } if (nofull) { for (int j = 0; j < 8; j++) { if (j < nofull) { printf("%c", ch[i]); i++; } else { printf("%d", 0); } } } return 0; }