1069 The Black Hole of Numbers (20 分)难度: 简单 / 知识点: 模拟

Posted 辉小歌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了1069 The Black Hole of Numbers (20 分)难度: 简单 / 知识点: 模拟相关的知识,希望对你有一定的参考价值。


https://pintia.cn/problem-sets/994805342720868352/problems/994805400954585088

#include<bits/stdc++.h>
using namespace std;
int main(void)
{
    string a,b; cin>>a;
    int sum=stoi(a);
    do
    {
        a=to_string(sum);
        while(a.size()<4) a="0"+a;
        sort(a.begin(),a.end());
        b=a,reverse(b.begin(),b.end());
        sum=stoi(b)-stoi(a);
        printf("%s - %s = %04d\\n",b.c_str(),a.c_str(),sum);
        if(sum==0) break;
    }while(sum!=6174);
}

以上是关于1069 The Black Hole of Numbers (20 分)难度: 简单 / 知识点: 模拟的主要内容,如果未能解决你的问题,请参考以下文章