1069. The Black Hole of Numbers (20)
来源:互联网 发布:类似我要当学霸的知乎 编辑:程序博客网 时间:2024/05/26 12:01
额,输入的可能不是四位数字
<span style="font-size:14px;">//注意这道题的输入可能不是4位数字,比如输入1,能否正确解读为0001#include<iostream>#include<cstdio>#include<algorithm>#include<cstdlib>#include<cstring>using namespace std;void deal(char *c,char*a,char*b){sort(c+0,c+4);strcpy(b,c);reverse(c+0,c+4);strcpy(a,c);//printf("a=%s\n",a);//printf("b=%s\n",b);}void build(char *a,char*b,char*c){int v = 1;int big,small;while(v!=6174 && v !=0){deal(c,a,b);big = atoi(a);small = atoi(b);v = big-small;printf("%04d - %04d = %04d\n",big,small,v);sprintf(c,"%04d",v);}}int main(){int buf;char c[10];char a[10];char b[10];cin>>buf;sprintf(c,"%04d",buf);build(a,b,c);return 0;}</span>
0 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)
- poj3660Cow Contest_Floyd传递闭包
- 数组指针和指针数组的区别
- ListView
- 动态链接库dll 静态链接库lib 动态导入库lib
- 2千万用户APP的开发运营流程
- 1069. The Black Hole of Numbers (20)
- Git仓库迁移而不丢失log的方法
- 插件模式
- 复高斯白噪声的产生与叠加方法总结
- iOS 自定义navigationItem
- Dijkstra 求最短路径算法
- C#与linux 时间戳互转
- ReactiveCocoa Tutorial – The Definitive Introduction
- intent.getSerializableExtra(转)