Example #1
0
int eight_queen(int index)
{
	int loop;
	for(loop = 0; loop < 8; ++loop){
		if(check_pos_valid(index, loop)){
			gEightQueen[index] = loop;
			if(7 == index){
				++gCount;
				print();
			    gEightQueen[index] = 0;
				return 0;
			}
			eight_queen(index + 1);
			gEightQueen[index] = 0;
		}
	}
	return 0;
}
Example #2
0
void eight_queen(int row)  
{  
    for(int col = 0; col < 8; col++){  
        if(check_pos_valid(row, col)){  
            gEightQueen[row] = col;  
  
            if(7 == row){  
                gCount ++;
                print();  
                //gEightQueen[row] = 0;  
                return;  
            }  
              
            eight_queen(row + 1);  
            //gEightQueen[row] = 0;
            //print();
            //printf("xx%dxx.\n", gTest++);
        }  
    }  
}