1069. The Black Hole of Numbers (20)
来源:互联网 发布:嵌入式和java哪个难学 编辑:程序博客网 时间:2024/05/16 00:49
1069. The Black Hole of Numbers (20)
#include <iostream>#include <algorithm>using namespace std;class CA{public:enum{digit_num=4,blackhole_num=6174};void run();int n;int goblackhole(int k);};int CA::goblackhole(int k){int a[digit_num],i,r1,r2;for(i=0;i<digit_num;i++){a[i]=k%10;k/=10;}sort(a,a+digit_num);r1=a[3]*1000+a[2]*100+a[1]*10+a[0];r2=a[0]*1000+a[1]*100+a[2]*10+a[3];printf("%04d - %04d = %04d\n",r1,r2,r1-r2);return r1-r2;}void CA::run(){scanf("%d",&n);while(n>0){n=goblackhole(n);if(n==blackhole_num) break;}}int main(){//freopen("test.in","r",stdin);CA *a=new CA;a->run();return 0;}
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- 1069. The Black Hole of Numbers (20)
- python学习笔记:二
- 不确定性原理的前世今生:傅里叶变换
- 反转句子中的单词顺序
- Android 个人学习笔记 ①
- 程序员网址大全
- 1069. The Black Hole of Numbers (20)
- 图像处理算法1——区域生长法
- poj 1330lca模板题离线算法
- memset()的效率以及源码分析
- 如何终止impdp/expdp
- Struts2基础知识
- hw 9.15
- 【索引】 Volume 7. Graph Algorithms and Implementation Techniques
- ORA-00119: invalid specification for system parameter LOCAL_LISTENER