View Code of Problem 101

#include <stdio.h>
#include <string.h>

int count(char x){
	if('0'<=x && x<='9') return 1;
	else return 0;
}

int main(){
	int index,tag;
	char str[100];
	//输入:1个字符串str
	while(scanf("%s", str)!=EOF){
		char str2[100]="";
		//处理
		int len = strlen(str);
		index=0; tag=0;
		for(int i=len-1; i>=0; i--){
			if(tag==3){
				str2[index++] = ',';
				tag=0;
			}
			if(count(str[i])==1){
				str2[index++] = str[i];
				tag++;
			}
		}
		len = strlen(str2);
		//输出:1个字符串 
		for(int i=len-1; i>=0; i--){
			printf("%c", str2[i]);
		}
		printf("\n");
	}
	
}

Double click to view unformatted code.


Back to problem 101