题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <stdio.h> #include<string.h> int main() { char str[100]; int cnt = 0; while (scanf("%s", str) != EOF) { //循环输入 int len = strlen(str); int i; for (i = 0; i < len; i++) { if (i > 0 && i % 8 == 0) { //按8分割 printf("\n"); cnt = 0; } printf("%c", str[i]); cnt++; //计数 } while (cnt < 8) { //不够补0 printf("0"); cnt++; } printf("\n"); } return 0; }
C语言刷题 文章被收录于专栏
自己从头开始刷的C语言