#include <iostream>
#include <limits>
#include <locale>
struct space_out : std::numpunct<char> {
char do_thousands_sep() const { return ' '; } // separate with spaces
std::string do_grouping() const { return "\1"; } // groups of 1 digit
};
int main()
{
int n;
while(!( std::cout << "Enter a three-digit integer: "
&& std::cin >> n
&& n > 99 && n < 1000))
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "This was not a three-digit integer, try again\n";
}
std::cout.imbue(std::locale(std::cout.getloc(), new space_out));
std::cout << n << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bGltaXRzPgojaW5jbHVkZSA8bG9jYWxlPgpzdHJ1Y3Qgc3BhY2Vfb3V0IDogc3RkOjpudW1wdW5jdDxjaGFyPiB7CiAgICBjaGFyIGRvX3Rob3VzYW5kc19zZXAoKSAgIGNvbnN0IHsgcmV0dXJuICcgJzsgfSAgIC8vIHNlcGFyYXRlIHdpdGggc3BhY2VzCiAgICBzdGQ6OnN0cmluZyBkb19ncm91cGluZygpIGNvbnN0IHsgcmV0dXJuICJcMSI7IH0gLy8gZ3JvdXBzIG9mIDEgZGlnaXQKfTsKaW50IG1haW4oKQp7CiAgICBpbnQgbjsKICAgIHdoaWxlKCEoICAgIHN0ZDo6Y291dCA8PCAiRW50ZXIgYSB0aHJlZS1kaWdpdCBpbnRlZ2VyOiAiCiAgICAgICAgICAgICAmJiBzdGQ6OmNpbiA+PiBuCiAgICAgICAgICAgICAmJiBuID4gOTkgJiYgbiA8IDEwMDApKQogICAgewogICAgICAgIHN0ZDo6Y2luLmNsZWFyKCk7CiAgICAgICAgc3RkOjpjaW4uaWdub3JlKHN0ZDo6bnVtZXJpY19saW1pdHM8c3RkOjpzdHJlYW1zaXplPjo6bWF4KCksICdcbicpOwogICAgICAgIHN0ZDo6Y291dCA8PCAiVGhpcyB3YXMgbm90IGEgdGhyZWUtZGlnaXQgaW50ZWdlciwgdHJ5IGFnYWluXG4iOwogICAgfQoKICAgIHN0ZDo6Y291dC5pbWJ1ZShzdGQ6OmxvY2FsZShzdGQ6OmNvdXQuZ2V0bG9jKCksIG5ldyBzcGFjZV9vdXQpKTsKICAgIHN0ZDo6Y291dCA8PCBuIDw8ICdcbic7Cn0K