visit[curPos] = 1; //如果这个点的三个方向都走过, 则将其置为visited状态
}
return 0;
}
int main(int argc, char *argv[])
{
ifstream input("input.txt");
if(!input)
{
cerr << "Can not open file: " << input << endl;
return -1;
}
NODE trace[NODE_COUNT + 1];
int index = 1;
while(input >> (trace[index].left))
{
input >> (trace[index].forward);
input >> (trace[index].right);
index++;
}
input.close();
getTrace(trace, 1);
reverse(traceVec.begin(), traceVec.end());
if(traceVec.size() > 0)
{
cout << "trace is: " << endl;
ostream_iterator<int> os(cout, " ");
copy(traceVec.begin(), traceVec.end(), os);
cout << endl;
}
else
cout << "no trace" << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
每个点有三个方向, 前, 左, 右...