with return value 3221225477

#include
#include
#define MAX 2
#include
using namespace std;

int n = 3;
const double dist[3][3]={0,1,2,
1,0,3,
2,3,0};

double shortestPath(vector& path,vector& visited,double currentLength){
if(path.size() == n)
return currentLength + dist[path[0]][path.back()];
double ret = 500;
for(int next=0;next<n;next++){
if(visited[next])
continue;
int here = path.back();
path.push_back(next);
visited[next] = true;
double cand = shortestPath(path,visited,currentLength+dist[here][next]);

          ret = min(ret,cand);
        visited[next] = false;
        path.pop_back(); 
}
return ret;

}

int main()
{

vector path;
vector visited(3,false);
double currentLength = 0;
double a = shortestPath(path,visited,currentLength);
cout<<"最短距离为:"<<a<<endl;
return 0;
}


vector path; 没有元素,传入shortest()后, 取back()值得到的是个未定义的随机值或者应该直接挂了吧?

毛估,应该有个地方没初始化