代码:
1 import java.util.*;
2 public class Main {
3 public static void main (String [] args) {
4 int num,digit1,digit2,digit3,digit4,newnum;
5 int temp;
6 Scanner s=new Scanner(System.in);
7 num=s.nextInt();
8 digit1=num/1000;
9 digit2=num/100%10;
10 digit3=num/10%10;
11 digit4=num%10;
12 digit1=(digit1+9)%10;
13 digit2=(digit2+9)%10;
14 digit3=(digit3+9)%10;
15 digit4=(digit4+9)%10;
16 temp=digit1;
17 digit1=digit3;
18 digit3=temp;
19 temp=digit2;
20 digit2=digit4;
21 digit4=temp;
22 newnum=digit1*1000+digit2*100+digit3*10+digit4;
23 System.out.println("The encrypted number is "+newnum);
24 }
25 }