import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int ans = ds(x)-xs(x);
if(ans==0){
System.out.printf("d - d = d\n",ds(x),xs(x),ans);
}else{
int n ;
do{
n = ds(x)-xs(x);
System.out.printf("d - d = d\n",ds(x),xs(x),n);
x = n;
}while(n!=6174);
}
}
public static int ds (int x){
int[]a = new int[4];
a[0] = x/1000;
a[1] = x/100;
a[2] = x/10;
a[3] = x;
Arrays.sort(a);
int sum = a[3]*1000+a[2]*100+a[1]*10+a[0];
return sum;
}
public static int xs (int x){
int[]a = new int[4];
a[0] = x/1000;
a[1] = x/100;
a[2] = x/10;
a[3] = x;
Arrays.sort(a);
int sum = a[0]*1000+a[1]*100+a[2]*10+a[3];
return sum;
}
}
4695 9654 - 4569 = 5085 8550 - 0558 = 7992 9972 - 2799 = 7173 7731 - 1377 = 6354 6543 - 3456 = 3087 8730 - 0378 = 8352 8532 - 2358 = 6174
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有