0001 #include "queen_brute_force_1/queen.h" 0002 0003 void place4Queens() { //4ʺ֦㷨 0004 int solu[4]; //ⷨ 0005 for ( solu[0] = 0; solu[0] < 4; solu[0]++ ) 0006 if ( !collide ( solu, 0 ) ) 0007 for ( solu[1] = 0; solu[1] < 4; solu[1]++ ) 0008 if ( !collide ( solu, 1 ) ) 0009 for ( solu[2] = 0; solu[2] < 4; solu[2]++ ) 0010 if ( !collide ( solu, 2 ) ) 0011 for ( solu[3] = 0; solu[3] < 4; solu[3]++ ) 0012 if ( !collide ( solu, 3 ) ) { 0013 nSolu++; displaySolution ( solu, 4 ); 0014 } 0015 }