某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字 都加上5,然后用和除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换
package hibernate; import java.util.Scanner; public class t { public static int shuzi() { Scanner s = new Scanner(System.in); System.out.println("请输入一个四位数:"); int i = s.nextInt(); return i; } public static int jiami(int i) { int a, aa, aaa, aaaa; a = i / 1000; aa = i / 100 % 10; aaa = i / 10 % 10; aaaa = i % 10; a = (a + 5) % 10; aa = (aa + 5) % 10; aaa = (aaa + 5) % 10; aaaa = (aaaa + 5) % 10; int o = 0; o = a; a = aaaa; aaaa = o; o = aa; aa = aaa; aaa = o; System.out.println("加密后的数字位为:" + a + aa + aaa + aaaa); return 0; } public static void main(String[] args) { int i = shuzi(); jiami(i); } }