int reverse(int number) {
int i, j, ret = 1;
int a = number%10;
int sum = 0;
int temp;
while (a == 0 && number != 0) {
number /= 10;
a = number%10;
}
temp = number;
for (i = 0; temp != 0; i++) {
temp /= 10;
}
for (; i > 0; i--) {
for (j = i, ret = 1; j > 1; j--) {
ret *= 10;
}
a = number%10;
sum += a*ret;
number /= 10;
}
return sum;
}```
习题6-6 使用函数输出一个整数的逆序数 (20分)
最新推荐文章于 2023-10-23 20:34:44 发布