| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
厉害,让我们菜鸟受益菲浅阿In Reply To:小弟写的八皇后,献丑了。 Posted by:Isun at 2008-10-14 15:41:58 > #include<stdio.h>
> int main ( )
> {
> int a,b,c,d,e,f,g,h;
> int result=0;
> for(a=0;a<8;a++){
> for(b=0;b<8;b++){
> if((b!=a+1&&b!=a-1)&&b!=a){
> for(c=0;c<8;c++){
> if((c!=b+1&&c!=b-1)&&(c!=a+2&&c!=a-2)&&(c!=a&&c!=b)){
> for(d=0;d<8;d++){
> if((d!=c+1&&d!=c-1)&&(d!=b+2&&d!=b-2)&&(d!=a+3&&d!=a-3)&&(d!=a&&d!=b&&d!=c)){
> for(e=0;e<8;e++){
> if((e!=d+1&&e!=d-1)&&(e!=c+2&&e!=c-2)&&(e!=b+3&&e!=b-3)&&(e!=a+4&&e!=a-4)&&(e!=a&&e!=b&&e!=c&&e!=d)){
> for(f=0;f<8;f++){
> if((f!=e+1&&f!=e-1)&&(f!=d+2&&f!=d-2)&&(f!=c+3&&f!=c-3)&&(f!=b+4&&f!=b-4)&&(f!=a+5&&f!=a-5)&&(f!=a&&f!=b&&f!=c&&f!=d&&f!=e)){
> for(g=0;g<8;g++){
> if((g!=f+1&&g!=f-1)&&(g!=e+2&&g!=e-2)&&(g!=d+3&&g!=d-3)&&(g!=c+4&&g!=c-4)&&(g!=b+5&&g!=b-5)&&(g!=a+6&&g!=a-6)&&(g!=a&&g!=b&&g!=c&&g!=d&&g!=e&&g!=f)){
> for(h=0;h<8;h++){
> if((h!=g+1&&h!=g-1)&&(h!=f+2&&h!=f-2)&&(h!=e+3&&h!=e-3)&&(h!=d+4&&h!=d-4)&&(h!=c+5&&h!=c-5)&&(h!=b+6&&h!=b-6)&&(h!=a+7&&h!=a-7)&&(h!=a&&h!=b&&h!=c&&h!=d&&h!=e&&h!=f&&h!=g)){
> printf("Result:%d [%d,%d,%d,%d,%d,%d,%d,%d]\n",++result,a,b,c,d,e,f,g,h);
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> }
> printf("Total:%d\n",result);
> // while(1);
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator