#include int Total(int num, int n) { if (num > 999) { return Total(num / 1000, n + 1); } else { return n; } } void New(int num, int n, int y) { if (num > 999) { New(num / 1000, n + 1, y); } if (n == y) { printf("%d", num); } else { printf("%3d", num % 1000); }; if (n > 1) printf(","); } int main() { int x, y; scanf("%d", &x); y = Total(x, 1); New(x, 1, y); return 0; }