View Code of Problem 101

#include <iostream>
using namespace std;

int main() {
	string a;
	while(cin >>a){
		string b;
		for(int i=0;i<a.length();i++){
			if(a[i]!=','){
				b+=a[i];
			}
		}
		//cout <<b<<endl;
		//cout <<b.length()<<endl;
		int k=0;
		for(int j=b.length();j>0;j--){
			if(j%3==1&&j!=1){
				cout <<b[k++]<<",";
			}
			else{
				cout <<b[k++];
			}
		}
		cout <<endl;
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 101