我的代码有问题。
这是我的主要内容。
int main()
{
cin>>xG>>yG;
int x,y;
cin>>x>>y;
int crrWay[200] = {0},
minWay[200] = {0},
minWayN = -1;
way(x, y, crrWay, 0, 0, minWay, minWayN, 0);
printWay(minWay, minWayN);
return 0;
}
这就是功能。
void way(int x, int y, int *crrWay, int& crrWayWeight, int l, int* minWay, int& minWayN, int& minWayWeight)
{
crrWay[2*l] = x;
crrWay[2*l+1] = y;
if( x < 0 || y < 0 || x > 10 || y > 10 )
return;
// Сравнява намерения път с минималния
if(x == xG && y == xG)
{
registerWay(crrWay, l+1, minWay, minWayN, crrWayWeight, minWayWeight);
return;
}
// Клетката е непроходима.
if(tempMaze[x][y]==0)
return;
tempMaze[x][y] = 0;
crrWayWeight+=maze[x][y];
// Рекурсивни обръщения към всеки от четирите съседа
way(x+1, y, crrWay, crrWayWeight, l+1, minWay, minWayN, minWayWeight);
way(x, y+1, crrWay, crrWayWeight, l+1, minWay, minWayN, minWayWeight);
way(x-1, y, crrWay, crrWayWeight, l+1, minWay, minWayN, minWayWeight);
way(x, y-1, crrWay, crrWayWeight, l+1, minWay, minWayN, minWayWeight);
// връщане назад
tempMaze[x][y] = 1;
}
代码无法编译。它说
1>c:\users\admin\documents\zad51.cpp(102): 错误 C2664: 'way' : 无法将参数 4 从 'int' 转换为 'int &'