#include<stdio.h> #include<string.h> #include<math.h> int main(){ char s[100]; char b[100]; while(gets(s)){ int k=0; for(int i=0;i<strlen(s);i++){ //把数字取出来放入数组 if(s[i]>='0'&&s[i]<='9'){ b[k]=s[i]; k++; } } for(int j=0;j<=k-1;j++){ //k为字符串长度 if((k-j)%3==0&&j!=0) printf(","); printf("%c",b[j]); } printf("\n"); } } |
Double click to view unformatted code.