题解 | #添加逗号#
添加逗号
https://www.nowcoder.com/practice/f51c317e745649c0900996fd3f683aed
#include <stdio.h> #include<string.h> int main() { char ch[10]; int i=0,j=0; scanf("%s",ch); int sz=strlen(ch); if(sz%3!=0&&sz/3!=0) {for(i=0;i<sz%3;i++) { printf("%c",ch[i]); } printf(",");} for(;i<sz;i++) { printf("%c",ch[i]); j++; if(j==3&&i!=sz-1) { j=0; printf(","); } } return 0; }