题解 | #小乐乐改数字#
小乐乐改数字
https://www.nowcoder.com/practice/fcd30aac9c4f4028b23919a0c649824d
#include <stdio.h> #include<math.h> int main() { int n = 0, tem = 0, sum = 0, i = 0; scanf("%d", &n); while (n) //n的值为0时循环结束 { tem = n % 10; //取个位的数值 if (tem % 2 == 0) sum = sum + 0 * pow(10, i++); else sum = sum + 1 * pow(10, i++); n /= 10; //把个位数删掉,即十进制右移一位 } printf("%d", sum); return 0; }