View Code of Problem 101

//逗号分割数
#include<stdio.h>
#include<math.h>
#include<string.h>
int main(){
	char a[1000];
	char b[1000];
	while(gets(a)){
		int l=strlen(a);
		int i;
		int j=0;
		int count=0;
		for(i=l-1;i>=0;i--){
			if(a[i]==','){
				continue;
			}
			if(count%3==0&&count!=0){
				b[j++]=',';
			}
			count++;
			b[j++]=a[i];
		} 
	for(i=j-1;i>=0;i--){
		printf("%c",b[i]);
	}
	printf("\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 101