C-study/01/3/3.c
2021-09-16 21:20:29 +08:00

33 lines
407 B
C

#include<stdio.h>
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;
}