由买买提看人间百态

topics

全部话题 - 话题: nqueue
(共0页)
l***b
发帖数: 125
1
来自主题: JobHunting版 - 晕了,有人用iteration解n queens么
随手写的,输出解的个数和wiki上一样,估计是对的吧,没仔细测
int g_nTotalSolutionNum = 0;
void PrintSolution(int *pPos, int nQueue)
{
if (pPos == NULL)
{
return;
}
for ( int i = 0; i < nQueue; ++i )
{
cout << pPos[i] << ", ";
}
cout << endl;
++g_nTotalSolutionNum;
}
void NQueue(int nQueue)
{
if ( nQueue == 0 )
{
return;
}
int *pPos = new int[nQueue];
int nCurrCol = 0;
pPos[0] = 0;

for(;;)
{
if ( pPos[nCurrCol] == nQueue )
... 阅读全帖
S**Y
发帖数: 136
2
来自主题: JobHunting版 - question 2: o(1) euque and dequeue?
Given a constant number of priorities implement a priority queue with O(1) e
nqueue and dequeue implementations.
I can not think of a way doing this...O(1) enque and deque..
even with a constant number of prioritties..
Any ideas?
d****n
发帖数: 233
3
来自主题: JobHunting版 - 晕了,有人用iteration解n queens么
Mark.
The following part at the end seems not needed:
if ( pPos[nCurrCol] == nQueue - 1 )
{
--nCurrCol;
++pPos[nCurrCol];
continue;
}
else
(共0页)