View Code of Problem 101

#include <iostream>
#include <string>
using namespace std;
int main() {
	string s;
	while ((cin >> s)) {
		int k = 0;
		while (1) {
			k = s.find(",");
			if (k == -1) break;
			s.erase(k, 1);
		}
		k = 1;
		cout << s[0];
		for (int i = s.size()-1; i > 0; --i)
		{
			if (!(i % 3)) {
				cout << ',';
			}
			cout << s[k++];
		}
		cout << endl;
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 101