Как работает приведённый рекурсивный метод? - C#
Формулировка задачи:
public bool find_path(int cur_x, int cur_y, int move_num) { Ar[cur_x, cur_y] = move_num; if (move_num > max_moves) return true; for (int i = 0; i < move_types; ++i) { int next_x = cur_x + possible_moves[i, 0]; int next_y = cur_y + possible_moves[i, 1]; if (move_possible(next_x, next_y) && find_path(next_x, next_y, move_num + 1)) return true; } Ar[cur_x, cur_y] = 0; --move_num; return false; }
return false
if (move_possible(next_x, next_y) && find_path(next_x, next_y, move_num + 1))
return false
if
Решение задачи: «Как работает приведённый рекурсивный метод?»
textual
Листинг программы
if (move_possible(next_x, next_y) && find_path(next_x, next_y, move_num + 1))