View Code of Problem 101

#include<iostream>
using namespace std;
int main(void){
	string s;
	while(getline(cin,s)){
		string b;
		int l=s.length(),j=0;
		for(int i=l-1;i>=0;i--){
			if(s[i]==',') continue;
			else{
				b+=s[i];
				j++;
			}
			if(j%3==0&&i!=0){
				 b+=",";
				 j=0;
			}
		}
		for(int i=b.length()-1;i>=0;i--){
			cout<<b[i];
		}
		cout<<endl;
	}
} 

Double click to view unformatted code.


Back to problem 101