int check(int value,unsigned char *mark)
{
#define MARK(x,mark) {if(x == 0) return 1; if(mark[x - 1] == 1) return 1; mark[x-1] = 1;}
int x;
x = value % 10;
MARK(x,mark);
if(value > 9)
{
x = value / 10 % 10;
MARK(x,mark);
}
if(value > 99)
{
x = value / 100 % 10;
MARK(x,mark);
}
return 0;
}
main()
{
int f,s;
unsigned char mark[9] = {0};
for(f = 0;f < 1000 ;f ++)
{
memset(mark,0,sizeof(mark));
if(check(f,mark)) continue;
s = f + 333;
if(check(s,mark))continue;
s += 333;
if(check(s,mark)) continue;
for(s = 0; s < 9; s ++)
if(mark[s] == 0) break;
if(s == 9)
printf("find value %d %d %dn",f,f + 333,f + 666);
}
}
运行最终结果
find value 123 456 789
find value 132 465 798
find value 213 546 879
find value 231 564 897
find value 312 645 978
find value 321 654 987