题解 | #小乐乐改数字#
小乐乐改数字
http://www.nowcoder.com/practice/fcd30aac9c4f4028b23919a0c649824d
#include<stdio.h> int main() { long long n = 0; scanf("%lld",&n); long long a = n; long long b = n; int i = 0; int j = 0; int arr[9]; while(1) { b = a%10;//取出余数 if(b%2 == 0) { b = 0; } if(b%2 != 0) { b = 1; } arr[i] = b; a = a/10; i++; if(a == 0) { break; } } int ret = 0; for(int j = i-1;j>=0;j--) { ret = ret*10+arr[j]; } printf("%d",ret);
return 0;
}