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