题解 | #小乐乐改数字#

小乐乐改数字

https://www.nowcoder.com/practice/fcd30aac9c4f4028b23919a0c649824d

#include <stdio.h>

int main() {
    int num,res = 0,weight = 1;
    scanf("%d",&num);

    while (num != 0) {
        int index = num % 10;
        if(index % 2)
            res += weight * 1;
        weight *= 10;
        num /= 10;
    }
    printf("%d",res);
    return 0;
}

不知道接下来该怎么优化

全部评论

相关推荐

点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务