给你一个参考代码,你使用递归要用一个变量存储每次递归处理的每一位的数值
#include <stdio.h>
long long reverseNumber(long long num) {
long long reversed = 0;
while (num != 0) {
reversed = reversed * 10 + num % 10;
num /= 10;
}
return reversed;
}
int main() {
long long number;
printf("请输入一个数字:");
scanf("%lld", &number);
long long reversed = reverseNumber(number);
printf("原始数字: %lld\n", number);
printf("倒序数字: %lld\n", reversed);
return 0;
}