70,014
社区成员




int BackTrace(int t, int x, int y,int m,int n)
{
if (t >= m * n)
{
p++;
OutPutChess(m,n);
///////////////////////////
return 1;
}
else
{
int i;
int count[8], possibleSteps[8];
int k = 0;
for (i = 0; i < 8; ++i)
{
if (canJump(x + Jump[i][0], y + Jump[i][1],m,n))
{
count[k] = weightStep(x + Jump[i][0], y + Jump[i][1],m,n);
possibleSteps[k++] = i;
}
}
inssort(count, possibleSteps, k);
for (i = 0; i < k; ++i)
{
int d = possibleSteps[i];
x += Jump[d][0];
y += Jump[d][1];
chess[x][y] = t + 1;
step[t] = d;
//////////////////////////////////
if (1 == BackTrace(t + 1, x, y,m,n)) {
return 1;
}
chess[x][y] = 0;
x -= Jump[d][0];
y -= Jump[d][1];
}
}
}