View Code of Problem 101

#include<iostream>
#include<algorithm> 
using namespace std;
int main()
{
	string s;
	while(cin>>s){
		reverse(s.begin(),s.end());
		string tmp;
		int count=0;
		for(int i=0;i<s.length();++i){
			if(s[i]>='0'&&s[i]<='9'){
				tmp+=s[i];
				count++;
				if(count==3){
					if(i!=s.length()-1){
						tmp+=',';
						count=0;
					}
				}
			}
			
		}
		reverse(tmp.begin(),tmp.end());
		tmp.clear();
		cout<<tmp<<endl;
	}
 } 

Double click to view unformatted code.


Back to problem 101