//这是到水题,之前因为四位数的原因一直不能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. mysql西文字符大小写重复键问题的解决方法

    ä和a插入到唯一键时总提示重复 总提示:Duplicate entry 'a' for key 'name' 后来发现我用的COLLATE是utf8_general_ci,改为utf8_bin即可,命 ...

  2. ui与ux的区别

  3. php 封装mysql 数据库操作类

    <?phpheader('content-type:text/html;charset=utf-8');//封装mysql   连接数据库php_mysql//封装mysql   连接数据库ph ...

  4. ice介绍 z

    什么是ICE(Internet Communications Engine)呢,它是由Zeroc公司开 发的一套开源中间件系统,与DCOM,CORBA,WEB SERVICEDcom类似,支持RPC( ...

  5. rubymine配置 rspec

    If you go in Run > Edit Configurations... And select All Specs in <Your Project> you'll see ...

  6. 初始化ArrayList的两种方法

    方式一:  ArrayList<String> list = new ArrayList<String>();  String str01 = String("str ...

  7. 基于spring-redis发布订阅模式的实现

    redis配置: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http ...

  8. Java中的装箱拆箱

    一)  装箱与拆箱 Java中有概念是一切皆对象,因为所有的类都默认继承自Object.但是,对于数据类型是个例外,如short,int,long,float,double, byte,char,bo ...

  9. shell local

    Shell函数定义的变量默认是global的,其作用域从"函数被调用时执行变量定义的地方"开始,到shell结束 http://blog.chinaunix.net/xmlrpc. ...

  10. 去掉 input type="number" 右边图标

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...