ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

PTA----- 数字加密 (15分)

2020-03-28 16:56:07  阅读:20  来源: 互联网

标签:10 加密 temp int PTA ++ printf 15 main


PTA----- 数字加密 (15分)

#include<stdio.h>
int main()
{
    int i = 3, x;
    int a[4];
    int temp;
    scanf("%d", &x);
    while (i != -1) 
    {
        a[i] = x % 10;
        x = x / 10;
        i--;
    }
    for (i = 0; i < 4; i++)
    {
        a[i] = a[i] + 9;
    }
    for (i = 0; i < 4; i++)
    {
        a[i] = a[i] % 10;
    }
    for (i = 0; i < 2; i++)
    {
        temp = a[i];
        a[i] = a[i + 2];
        a[i + 2] = temp;
    }
    printf("The encrypted number is ");
    for (i = 0; i < 4; i++)
    {
        printf("%d", a[i]);
    }
    return 0;
}

标签:10,加密,temp,int,PTA,++,printf,15,main
来源: https://blog.51cto.com/14737345/2482679

专注分享技术,共同学习,共同进步。侵权联系[admin#icode9.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有