#include<bits/stdc++.h>
using namespace std;
int main(){
int a;
cin>>a;
int big=4,small=6;
while(big - small != 6174 && big != small){
string bigstr = to_string(a);
while(bigstr.length()!=4){
bigstr = '0'+bigstr;
}
string smallstr(bigstr);
sort(bigstr.rbegin() , bigstr.rend());
sort(smallstr.begin() , smallstr.end());
big = stoll(bigstr);
small = stoll(smallstr);
printf("%04d - %04d = %04d\n",big,small,big-small);
a = big - small;
}
}
一定要进行填充,就是9998-8999 = 0999.
下一步是9990 - 0999.
并不是简单的把相减后的数字进行填充