A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

  1.                 int x = 9472;
  2.                 int first = x/1000;
  3.                 int second = (x-first*1000)/100;
  4.                 int third = (x-first*1000-second*100)/10;
  5.                 int fourth = x-first*1000-second*100-third*10;
  6.                 System.out.println(first);
  7.                 System.out.println(second);
  8.                 System.out.println(third);
  9.                 System.out.println(fourth);
  10.                 first = (first+5)%10;
  11.                 second = (second+5)%10;
  12.                 third = (third+5)%10;
  13.                 fourth = (fourth+5)%10;
  14.                 int newX = fourth*1000+third*100+second*10+first;
  15.                 System.out.println(newX);
复制代码


数据是四位的整数,在传递过程中是加密的,

加密规则如下:
每位数字都加上5,然后用和除以10的余数代替该数字,
再将第一位和第四位交换,第二位和第三位交换。

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马