- int x = 9472;
- int first = x/1000;
- int second = (x-first*1000)/100;
- int third = (x-first*1000-second*100)/10;
- int fourth = x-first*1000-second*100-third*10;
- System.out.println(first);
- System.out.println(second);
- System.out.println(third);
- System.out.println(fourth);
- first = (first+5)%10;
- second = (second+5)%10;
- third = (third+5)%10;
- fourth = (fourth+5)%10;
- int newX = fourth*1000+third*100+second*10+first;
- System.out.println(newX);
复制代码
数据是四位的整数,在传递过程中是加密的,
加密规则如下:
每位数字都加上5,然后用和除以10的余数代替该数字,
再将第一位和第四位交换,第二位和第三位交换。
|
|