题解 | #小乐乐改数字#
小乐乐改数字
https://www.nowcoder.com/practice/fcd30aac9c4f4028b23919a0c649824d
#include <stdio.h>
int main() {
int a;
int dms = 0;
scanf("%d",&a);
int times,j ;
for(int i=0;i<10;i++){
if(i == 0){ //初次运行时要给times赋初值
j = a%10;
times = 1;
a = a/10;
if(j%2 == 1)
dms += times;
}
else if(a >= 10){ //条件的判断记得加上=,否则出现10时会出现BUG
j = a%10;
times = times*10;
a = a/10;
if(j%2 == 1)
dms += times;
}
else {
times = times*10;
if (a%2 == 1)
dms += times;
break; //判断后面没有数据了,给他跳出来
}
}
printf("%d",dms);
return 0;
}
美的集团公司福利 727人发布