View Code of Problem 101

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main (){
	char s[1010];
	while(gets(s)){
		char str[1010];
		int k = 0, cnt = 0;
		for(int i = strlen(s)-1;i >= 0;i--){
			if(s[i]==',') continue;
			if(cnt%3==0&&cnt!=0) str[k++] = ',';
			cnt++;
			str[k++] = s[i];
		}
		for(int i = k-1;i >= 0;i--){
			printf("%c", str[i]);
		}
		printf("\n");
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 101