题目标题:数字转换(谌海军)

题目描述: 输入一个数字,大小<100000,将其中每位数字进行转换后输出,规则如下:数字0与9互换、1与8互换、2与7互换、3与6互换、4与5互换。 注意:要考虑首位数字为9时的转换结果。 输入描述: 输入数据为1个数字,大小<100000 输出描述: 输出为1个根据转换规则转换完成后的数字 样式输入: 56789 样式输出: 43210

#include <stdio.h>

int main() {
    int num, temp;
    scanf("%d", &num);
    while (num != 0) {
        temp = num % 10;
        if (temp == 0) {
            printf("9");
        } else if (temp == 1) {
            printf("8");
        } else if (temp == 2) {
            printf("7");
        } else if (temp == 3) {
            printf("6");
        } else if (temp == 4) {
            printf("5");
        } else if (temp == 5) {
            printf("4");
        } else if (temp == 6) {
            printf("3");
        } else if (temp == 7) {
            printf("2");
        } else if (temp == 8) {
            printf("1");
        } else if (temp == 9) {
            printf("0");
        }
        num /= 10;
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值