题解 | 反向输出一个四位数
反向输出一个四位数
https://www.nowcoder.com/practice/1f7c1d67446e4361bf4af67c08e0b8b0
#include <stdio.h>
int main(void) {
int n = 0;
scanf("%d", &n);
//获取个位数
int digit = n % 10;
//获取十位数
int ten = (n - digit) / 10 % 10;
//获取百位
int hundred = (n - digit - 10 * ten) / 100 % 10;
//获取千位
int thousand = (n - digit - 10 * ten - 100 * hundred) / 1000 % 10;
printf("%d%d%d%d\n", digit, ten, hundred, thousand);
return 0;
}
