#include <stdio.h>
int maxof3 (int,int,int);
int minof3 (int,int,int) ;
void main()
int i,k;
int. hun , oct, data, max, min,j,h;
printf(”请输入一个三位数:");
scanf("%d", &i);
hun=i/100;
oct=i%100/10;data=i%10;
max=maxof3 (hun, oct, data);min-minof3 (hun, oct, data);j=max-min;
for(k=0;;k++)
/*k控制循环次数*/
h=j;
/*h记录上一次最大值与最小值的差*/
hun=j/100;
oct=j%100/10;data=j%10;
max=maxof3(hun, oct, data);min-minof3 (hun, oct, data);j-max-min;
if(j==h)
/*最后两次差相等时,差即为所求黑洞数*/
printf ( "%d\\n", j);
版, break;
/*跳出循环*/
int maxof3 (int a, int b, int c)
int t;
if(a<b)
/*如果a<b,将变量a、b的值互换*/
(
t=a;
a=b;
b=t;
if(a<c)
t=a;
a=c;c=t;
if(b<c)
t=b;b=c;c=t;
return (a*100+b*10+c);
int minof3(int a,int b,int c)
int t;
if(a<b)
t=a;a=b;b=t;
if(a<c)
t=a;a=c;c=t;
if(b<c)
t=b;b=C;c=t;
return(c*100+b*10+a);