黑洞数
/problem-sets/1325975206586703872/problems/1325979500962603009
#include<stdio.h>
int main(void)
{
int one,two,three;
int digit=0;
int big=0,small=0;
int i,j,k;
int input;
int box[10]={0,0,0,0,0,0,0,0,0,0};
scanf("%d",&input);
for(i=1;-1;i++)
{
one = input%10;
two = input/10%10;
three = input/100;
box[one]++;
box[two]++;
box[three]++;
for(j=1;j<=9;j++)
{
for(k=box[j];-1;k--)
{
if(k!=0)small = small*10+j;
else break;
}
}//printf("small = %d\n",small);
for(j=9;0<=j;j--)
{
for(k=box[j];-1;k--)
{
if(k!=0)big = big*10+j;
else break;
}
}//printf("big = %d\n",big);
input = big-small;
printf("%d: %d - %d = %d\n",i,big,small,input);
if(one==two&&two==three)break;
if(input==495)break;
big=0;small=0;
for(j=0;j<=9;j++){box[j]=0;}
}
return 0;
}