#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
bool cmp(char a,char b){
return a > b;
}
int main(){
int n,a,b,c;
char s[4];
scanf("%d",&n);
do{
for(int i = 3;i >= 0;i --){
s[i] = n%10 + '0';
n /= 10;
}
sort(s,s + 4);
b = atoi(s);
sort(s,s + 4,cmp);
a = atoi(s);
c = a - b;
printf("%04d - %04d = %04d\n",a,b,c);
n = c;
}while(c != 6174 && c != 0);
return 0;
}
1069. The Black Hole of Numbers
最新推荐文章于 2021-08-13 21:35:33 发布