Thread: a question2
View Single Post
  #1 (permalink)  
Old August 14th, 2003, 08:12 AM
aliakbar aliakbar is offline
Registered User
 
Join Date: Aug 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default a question2

Thank you for your answer.
but this is a part of my program:
void pathfind(int x,int y,int **map){


if((x!=1 || y!=5) && (x>=1 && x<=5) && (y>=1 && y<=5)){
y++;
if((y)<=5 && map[y][x]){
count++;

pathfind(x,y,map);

}else{
y=y-(1);
count=0;count1=0;
}
x--;
if((x)>=1 && map[y][x]){
count1++;


pathfind(x,y,map);
}else{
x=x+(1);
count1=0;count2=0;
}
x--;y++;
if((x)>=1 && (y)<=5 && map[y][x]){
count2++;

pathfind(x,y,map);
}else{
x=x+(1);
y=y-(1);
count2=0;count3=0;
}
x--;y--;
if((x)>=1 && (y)>=1 && map[y][x]){
count3++;

pathfind(x,y,map);
}else{
x=x+(1);
y=y+(1);
count3=0;count4=0;
}
y--;
if((y)>=1 && map[y][x]){
count4++;

pathfind(x,y,map);
}else{
y=y+(1);
count4=0;count5=0;
}
x++;y--;
if((x)<=5 && (y)>=1 && map[y][x]){
count5++;

pathfind(x,y,map);
}else{
x=x-(1);
y=y+(1);
count5=0;count6=0;
}
x++;
if((x)<=1 && map[y][x]){
count6++;

pathfind(x,y,map);
}else{
x=x-(1);
count6=0;count7=0;
}
x++;y++;
if((x)<=1 && (y)<=1 && map[y][x]){
count7++;

pathfind(x,y,map);
}

}


}
my problem is that this program check the way only one time
and it doesnot check all of ways for finding shortest way.
what do i do for solving this problem.
Thank you.
regards.

Reply With Quote