华为机试-字符串分割(HJ104)-纯C
字符串分割
https://www.nowcoder.com/practice/fa2e02625a8541beb2309fcb7ab31e5b?tpId=37&&tqId=21327&rp=1&ru=/ta/huawei&qru=/ta/huawei/question-ranking
纯C
#include <stdlib.h> #include <stdio.h> #include <string.h> int main() { int n=0; while(scanf("%d", &n) != EOF) { char str[100] = {'\0'}; for(int i=0; i<n; i++) { scanf("%s", str); int len=strlen(str); char *pstr = str; while(len > 8) { for(int i=0; i<8; i++) { printf("%c", *(pstr++)); } printf("\n"); len -= 8; } printf("%s", pstr); len = 8-len; while(len) { printf("0"); len--; } printf("\n"); } } return 0; }