输入一个四位数,将其加密后输出。方法是将该数每一位上的数字加9,然后除以10取余,做为该位上的新数字,最后将千位和十位上的数字互换,百位和个位上的数字互换,组成加密后的新四位数。例如输入1257,经过加9取余后得到新数字0146,再经过两次换位后得到4601。
输入格式:
输入在一行中给出一个四位的整数x,即要求被加密的数。
输出格式:
在一行中按照格式“The encrypted number is V”输出加密后得到的新数V。
输入样例:
1257
输出样例:
The encrypted number is 4601
/*#include
int main(){
int x, a, b, c, d, sum;
scanf("%d",&x);
a = x % 10;
b = x / 10 % 10;
c = x / 100 % 10;
d = x / 1000;
a = (a + 9) % 10;
b = (b + 9) % 10;
c = (c + 9) % 10;
d = (d + 9) % 10;
sum = c + d * 10 + a * 100 + b * 1000;
printf("The encrypted number is %d", sum);
return 0;
}*/
#include
int main() {
int x, i=0, a[5]={0}, n;
scanf("%d", &x);
while(x){
a[i++] = (x % 10 + 9) % 10;
x /= 10;
}
n = i;
for(i = 0; i < n / 2; i++)
{
x = a[i], a[i] = a[i + 2], a[i + 2] = x;
}
for(i = n - 1,x = 0;i >= 0; i--)
x = x * 10 + a[i];
printf("The encrypted number is %d", x);
return 0;
}
#include <stdio.h>
int main()
{
int a,b,c,d;
scanf("%d",&a);
d=a%10;
a/=10;
c=a%10;
a/=10;
b=a%10;
a/=10;
a=(a+9)%10;
b=(b+9)%10;
c=(c+9)%10;
d=(d+9)%10;
a=1000*c+100*d+10*a+b;
printf("The encrypted number is %04d",a);
}