int sum(int x) {
int sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}
求任意一整数的各位数和
最新推荐文章于 2021-04-14 16:54:53 发布
int sum(int x) {
int sum = 0;
while (x > 0) {
sum += x % 10;
x /= 10;
}
return sum;
}