May someone explain this

Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  Put thebool r_exist[8]={false}, d1_exist[15]={false}, d2_exist[15]={false};

void search(int c) {
	if ( c==8 ) {
	cnt++;
	cout<<"Solution #"<<cnt<<":";
	for(int i=0;i<8;i++)cout<<" "<<row_posn[i]+1;
	cout<<endl;

	}
	if ( c==col ) search(c+1);
	else { 
	for(int r=0;r<8;r++){
		if(!r_exist[r] &&!d1_exist[r+c] && !d2_exist[7+r-c]){
			row_posn[c]=r;
			r_exist[r]=d1_exist[r+c]=d2_exist[7+r-c]=true;
		search(c+1);
		r_exist[r]=d1_exist[r+c]=d2_exist[7+r-c]=false;
		}
		
	}
	   
	   
	   
	} 

}

int main(){

	cin >> row >> col;
	row--;
	col--;
	row_posn[col]=row;
	r_exist[row]=d1_exist[row+col]=d2_exist[7+row-col]=true;

	
	search(0);
	return 0;
}


 code you need help with here.
> Write your question here.
I wonder what you mean? :-)
http://www.cplusplus.com/forum/beginner/194380/
Topic archived. No new replies allowed.