package fff;
import java.util.Scanner;
public class Yyy {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print1n("输入一个四位数的数");
int i =sc.nextInt();
//原来的方法错误,更加好计算,要放进数组里
int []arr = new int [4];
arr[0]=i/1000%10;
arr[1]= i/100%10;
arr[2]=i/10%10;
arr[3]=i%10;
for (int j = 0; j < arr.length; j++) {
arr[j]= (arr[j]+5)%10;
}
JiaMi(arr);
}
public static void JiaMi(int []arr){
for (int j = 0; j < arr.length/2; j++) {
int temp = arr[j];
arr[j] = arr[arr.length-1-j];
arr[arr.length-1-j] =temp;
}
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i]);
}
}
}
|
|