#include <stdio.h> #include <math.h> int main() { int a; scanf("%d", &a); int i = a, count = 0; while (i / 10) { count++; i /= 10; } if (a > 999) { while (count) { while (count % 3 != 0) count--; printf("%d,", a / (int)pow(10, count)); a %= (int)pow(10, count); count -= 3; } printf("%03d", a); } else { printf("%d", a); } return 0; }