Guest User

Untitled

a guest
Jan 16th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. int FindMin(int roads[N][N],int i,int min,int lenght,int houses_visited[4])
  2. {
  3.  
  4. if (check_full(houses_visited)==4 && i == 0){
  5. return lenght; // come in the if when its over but continue
  6. }
  7. if (check_full(houses_visited)==4 && i!= 0){
  8. return NO_PATH;
  9. }
  10.  
  11.  
  12. for (int j=0;j<N;j++) {
  13. if (roads[i][j] == -1 ||(houses_visited[j] == 1 && i!=3)|| i ==j){
  14. continue;
  15. }
  16.  
  17.  
  18. houses_visited[i] = 1;
  19. lenght = lenght + roads[i][j];
  20.  
  21. FindMin(roads,j,min,lenght, houses_visited);
  22. houses_visited[i] = 0; // here
  23. lenght = lenght - roads[i][j];
  24. }
  25.  
  26.  
  27. return lenght;
  28. }
Add Comment
Please, Sign In to add comment