View Code of Problem 101

#include<bits/stdc++.h>
using namespace std;

int main() {

	string s;
	while(getline(cin,s)){
		while(s.find(',')!=-1){
			int k=s.find(',');
			s.erase(k,1);
		}
		int num=0;
		for(int i=s.length();i>=0;i--){
			if(num==3&&i!=0){
				num=0;s.insert(i,",");
			}
			num++;
		}
		cout<<s<<endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 101