题解 | #小乐乐改数字#
小乐乐改数字
https://www.nowcoder.com/practice/fcd30aac9c4f4028b23919a0c649824d
#include <stdio.h> #include <math.h> int main() { int arr[100] = {0}; int n = 0; int i = 0; int tmp = 0; int sum = 0; scanf("%d", &n); while (n) { tmp = n % 10; if (tmp % 2 == 0) { arr[i] = 0; } else { arr[i] = 1; } n = n / 10; i++; } int j = 0; for (j = 0; j < i; j++) { sum = sum + arr[j] * (int)pow(10, j); } printf("%d", sum); return 0; }