View Code of Problem 101

#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<climits>
#include<cmath>
#include<unordered_map>
#include<set>

using namespace std;

int main()
{
	string str;
	while (cin >> str) {

		string temp;
		for (int i = 0; i < str.size(); i++) {

			if (str[i] != ',')
				temp += str[i];
		}

		string res;
		int pos = 0;
		for (int i = temp.size() - 1; i >= 0 ; i--) {

			res = temp[i] + res;
			pos++;
			if (pos == 3 && i != 0) {

				res = ',' + res;
				pos = 0;
			}
				
		}

		cout << res << endl;
	}
}

Double click to view unformatted code.


Back to problem 101