题解 | #小乐乐改数字#

小乐乐改数字

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

#include <stdio.h>
#include <string.h>

char s[15];

int main()
{
    int n;
    scanf("%d", &n);

    sprintf(s, "%d", n);

    for (int i = 0; i < strlen(s); i ++ )
    {
        if ((s[i] - '0') % 2 == 0) s[i] = '0';
        else s[i] = '1';
    }

    int res = 0;

    for (int i = 0; i < strlen(s); i ++ )
    {
        res = res * 10 + (s[i] - '0');
    }

    printf("%d", res);

    return 0;
}

全部评论

相关推荐

_hengheng:美赛啥时候有三等奖了,蓝桥杯优秀奖最好也别写,知道的面试官看了容易出事,能有菊厂实习也不算菜了
点赞 评论 收藏
转发
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务