添加0126.骑士的攻击astar C语言 版本

This commit is contained in:
Kuxry
2024-10-30 10:34:03 +09:00
parent 28de17ec39
commit ef36f40e43

View File

@ -500,7 +500,7 @@ int astar(int start_x, int start_y, int goal_x, int goal_y) {
Knight start;
start.x = start_x;
start.y = start_y;
start.g = 0; // 从起点到起点的消耗为 0
start.g = 0;
start.h = heuristic(start_x, start_y, goal_x, goal_y);
start.f = start.g + start.h; // 总的估计消耗
@ -547,7 +547,7 @@ int main() {
scanf("%d %d %d %d", &a1, &a2, &b1, &b2);
int result = astar(a1, a2, b1, b2); // 使用 A* 算法计算最短路径
printf("%d\n", result); // 输出所需的最小移动次数
printf("%d\n", result); // 输出最小移动次数
}
return 0;
}