//这是到水题,之前因为四位数的原因一直不能A,看了别人的程序,才明白,不够四位的时候没考虑到,坑啊。。。。。脸打肿

#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
//freopen("input.txt","r",stdin);
int i,n,s[5];
while(scanf("%d",&n)!=EOF)
{
while(1)
{
int len=0;
fill(s,s+4,0);
for(i=0;i<4;i++)
{
s[3-i]=n%10;
n/=10;
}
sort(s,s+4);
int n1=0,n2=0;
for(i=0;i<4;i++)
{
n1=n1*10+s[i];
n2=n2*10+s[4-1-i];
}
n=n2-n1;
printf("%04d - %04d = %04d\n",n2,n1,n);
if(n==0||n==6174)break;
}
}
return 0;
}

PAT1069. The Black Hole of Numbers的更多相关文章

  1. pat1069. The Black Hole of Numbers (20)

    1069. The Black Hole of Numbers (20) 时间限制 100 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, ...

  2. PAT 1069 The Black Hole of Numbers

    1069 The Black Hole of Numbers (20 分)   For any 4-digit integer except the ones with all the digits ...

  3. PAT 1069 The Black Hole of Numbers[简单]

    1069 The Black Hole of Numbers(20 分) For any 4-digit integer except the ones with all the digits bei ...

  4. 1069. The Black Hole of Numbers (20)【模拟】——PAT (Advanced Level) Practise

    题目信息 1069. The Black Hole of Numbers (20) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B For any 4-digit inte ...

  5. pat 1069 The Black Hole of Numbers(20 分)

    1069 The Black Hole of Numbers(20 分) For any 4-digit integer except the ones with all the digits bei ...

  6. PAT 甲级 1069 The Black Hole of Numbers (20 分)(内含别人string处理的精简代码)

    1069 The Black Hole of Numbers (20 分)   For any 4-digit integer except the ones with all the digits ...

  7. PAT_A1069#The Black Hole of Numbers

    Source: PAT A1069 The Black Hole of Numbers (20 分) Description: For any 4-digit integer except the o ...

  8. 1069 The Black Hole of Numbers (20分)

    1069 The Black Hole of Numbers (20分) 1. 题目 2. 思路 把输入的数字作为字符串,调用排序算法,求最大最小 3. 注意点 输入的数字的范围是(0, 104), ...

  9. 1069. The Black Hole of Numbers (20)

    For any 4-digit integer except the ones with all the digits being the same, if we sort the digits in ...

随机推荐

  1. PHP 正则表达式常用函数使用小结

    在PHP中有两套正则表达式函数库.一套是由PCRE(Perl Compatible Regular Expression)库提供的.PCRE库使用和Perl相同的语法规则实现了正则表达式的模式匹配,其 ...

  2. vim制作c的IDE

    编译vim源码 (1)安装依赖 sudo apt-get install python-dev python3-dev ruby-dev libx11-dev libgtk2.0-dev libgtk ...

  3. zookeeper进行leader选举

    一.如何进行leader选举 创建 /lj/producer和/lj/master/producer外层节点 创建临时顺序节点 判断自己是否是master节点(判断流程:遍历/lj/producer节 ...

  4. MyEclipse背景色不伤眼+字体大小调节+代码格式化不换行

  5. [Android Exception 1A] -com.android.volley.NoConnectionError: java.io.InterruptedIOException

    - ::-/com.tongyan.tutelage W/System.err: com.android.volley.NoConnectionError: java.io.InterruptedIO ...

  6. NSString类的相关用法

    一.NSString字符串连接NSString* string; // 结果字符串 NSString* string1, string2; //已存在的字符串 1. string = [NSStrin ...

  7. [实变函数]2.1 度量空间 (metric space), $n$ 维 Euclidean 空间

    1 回忆:    $$\bex    \lim_{n\to\infty}a_n=a\lra \forall\ \ve>0,\ \exists\ N,\ \forall\ n\geq N,\mbo ...

  8. UCOS-信号量(学习笔记)

    当事件控制块类型为OS_Event_Type_SEM类型时就是信号量,包含2个内容:信号量计数器OSEventcnt和等待列表OSEventTbl[]. 一创建信号量:OSSemCreat(int16 ...

  9. ylbtech-dbs:ylbtech-7,welfareSystem(福利发放系统)

    ylbtech-dbs:ylbtech-7,welfareSystem(福利发放系统) -- =============================================-- Datab ...

  10. Yii2.0 数据库查询方法

    User::find()->all();    此方法返回所有数据:    User::findOne($id);   此方法返回 主键 id=1  的一条数据(举个例子):    User:: ...