1: A company uses a public telephone to pass data, and the data is a four-bit integer that is encrypted during delivery.
The encryption rules are as follows: Each digit is prefixed with 5, and the remainder is replaced with and divided by 10, then the first and fourth bits are exchanged, and the second and third bits are exchanged.
Package Cn.zzsxt.lianxi;
Import Java.util.Scanner;
public class Practice {
public static void Main (string[] args) {
System.out.println ("Please enter a four-digit number:");
Scanner input = new Scanner (system.in);
int num = Input.nextint ();
int ge=num%10;
int shi=num/10%10;
int bai=num/100%10;
int qian=num/1000;
Ge= (ge+5)%10;
Shi= (shi+5)%10;
Bai= (bai+5)%10;
Qian= (qian+5)%10;
int tem=ge;
Ge=qian;
Qian=tem;
Tem=shi;
Shi=qian;
Qian=tem;
System.out.println ("Post-encryption number" +ge+shi+bai+qian);
}
}
Java Encryption Program Small example