Home > Back-end >  For help
For help

Time:12-29

8 * 8 board placed five queen, in turn, printing code implementation of 65 independent solution, what a great god can help me

CodePudding user response:

Fyi:
 # include & lt; stdio.h> 
Int d [8] [8];
int n;
Void queen8 (int L) {
Int x, y;

If (8==L) {
N++;
Printf (" % d \ n ", n);
For (y=0; y<8; Y++) {
For (x=0; x<8; X++) {
//printf (" % d ", d [y] [x]).
If (d [y] [x]) printf (" s ");
The else printf (" - ");
}
printf("\n");
}
return;
}
For (x=0; x<8; X++) {
For (y=0; yIf (d [y] [x]
| | (x - (L - y) & gt;=0 & amp; & D [y] [x - (L - y)])
| | (x + (L - y) & lt; 8 & amp; & D [y] [x + (L - y)]))
break;
}
If (y>=L) {
D [L] [x]=1;
Queen8 (L + 1);
D [L] [x]=0;
}
}
}
Int main () {
Int y, x;
For (y=0; y<8; Y++) {
For (x=0; x<8; X++) {
D [y] [x]=0;
}
}
Queen8 (0);
return 0;
}

CodePudding user response:

reference 1/f, zhao teacher reply:
are for reference only:
 # include & lt; stdio.h> 
Int d [8] [8];
int n;
Void queen8 (int L) {
Int x, y;

If (8==L) {
N++;
Printf (" % d \ n ", n);
For (y=0; y<8; Y++) {
For (x=0; x<8; X++) {
//printf (" % d ", d [y] [x]).
If (d [y] [x]) printf (" s ");
The else printf (" - ");
}
printf("\n");
}
return;
}
For (x=0; x<8; X++) {
For (y=0; yIf (d [y] [x]
| | (x - (L - y) & gt;=0 & amp; & D [y] [x - (L - y)])
| | (x + (L - y) & lt; 8 & amp; & D [y] [x + (L - y)]))
break;
}
If (y>=L) {
D [L] [x]=1;
Queen8 (L + 1);
D [L] [x]=0;
}
}
}
Int main () {
Int y, x;
For (y=0; y<8; Y++) {
For (x=0; x<8; X++) {
D [y] [x]=0;
}
}
Queen8 (0);
return 0;
}

Thanks to the teacher for help??
  • Related