题解 | #添加逗号#
添加逗号
https://www.nowcoder.com/practice/f51c317e745649c0900996fd3f683aed
#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;
}

查看18道真题和解析