浙大PAT 1069题 1069. The Black Hole of Numbers
来源:互联网 发布:淘宝店铺利益点介绍 编辑:程序博客网 时间:2024/05/18 23:55
#include<stdio.h>#include<stdlib.h>int cmp1(const void* ta,const void* tb){ int* a=(int*)ta; int* b=(int*)tb; return *b-*a;}int cmp2(const void* ta,const void* tb){ int* a=(int*)ta; int* b=(int*)tb; return *a-*b;}int main(){ int i,j,n; int last=-1,big,small,ans; int a[4],b[4]; scanf("%d",&n); while(1){ for(i=0;i<4;i++){ a[i]=b[i]=n%10; n=n/10; } qsort(a,4,sizeof(int),cmp1); qsort(b,4,sizeof(int),cmp2); big=a[0]*1000+a[1]*100+a[2]*10+a[3]; small=b[0]*1000+b[1]*100+b[2]*10+b[3]; ans=big-small; if(ans==last) break; else { printf("%04d - %04d = %04d\n",big,small,ans); last=ans; n=ans; } } return 0;}
0 0
- 浙大PAT 1069题 1069. The Black Hole of Numbers
- PAT 1069. The Black Hole of Numbers
- PAT 1069. The Black Hole of Numbers
- pat 1069. The Black Hole of Numbers
- PAT--1069. The Black Hole of Numbers
- PAT-The Black Hole of Numbers (20)
- 【PAT】1069. The Black Hole of Numbers (20)
- PAT (Advanced) 1069. The Black Hole of Numbers (20)
- PAT 1069. The Black Hole of Numbers (stringstream)
- PAT A 1069. The Black Hole of Numbers (20)
- PAT 1069. The Black Hole of Numbers (20)
- pat 1069. The Black Hole of Numbers (20)
- PAT 1069. The Black Hole of Numbers (20)
- PAT 1069. The Black Hole of Numbers (20)
- PAT-A 1069. The Black Hole of Numbers
- PAT(甲级)1069. The Black Hole of Numbers (20)
- PAT甲级练习1069. The Black Hole of Numbers (20)
- PAT-A 1069. The Black Hole of Numbers (20)
- qsort和sort的区别
- tomcat startup.sh提示java.lang.OutOfMemoryError: PermGen space
- VC界面
- 网站首页没被收录的原因
- 基于STM32的学习型通用红外遥控设备的设计实现(一)
- 浙大PAT 1069题 1069. The Black Hole of Numbers
- C语言有哪些关键字
- php redis 命令
- IOS类似新浪微博统计汉字/英文/标点符号等字符长度
- DHCP工作过程详解
- 协同程序
- 两个区间第K大问题
- List的遍历方法
- 在java代码中显示json字符串(怎么避免json字符串中双引号在java代码中显示)