BUPT-homework/semester1/pset7/4-reverseNum.c

22 lines
344 B
C
Raw Permalink Normal View History

2021-11-04 20:25:05 +08:00
// #include <stdio.h>
//
// int reverseNum(int num);
//
// int main() {
// int num;
//
// scanf("%d", &num);
// printf("The reverse form of number %d is %d.\n", num, reverseNum(num));
//
// return 0;
// }
int reverseNum(int num) {
int ans = 0;
while (num > 0) {
ans = ans * 10 + num % 10;
num /= 10;
}
return ans;
}