题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string num;
cin>>num;
while(num.length()<4){
num="0"+num;
}
while(1){
sort(num.rbegin(),num.rend());//降序
string num1=num;
sort(num.begin(),num.end());//升序
string num2=num;
if(num1==num2){
cout<<num1<<" - "<<num2<<" = 0000"<<endl;
break;
}
num=to_string(stoi(num1)-stoi(num2));
cout<<num1<<" - "<<num2<<" = "<<num<<endl;
if(num=="6174") break;
}
return 0;
}