把一个迷宫用图的邻接表表示。再来通过图的遍历求最长路径。c语言版 #include const a[10][10]={ {0,0,0,0,0,0,0,0,0,0}, {0,0,1,1,0,0,0,0,1,0}, {0,1,1,0,0,1,1,1,1,0}, {0,0,1,0,1,1,0,1,1,0}, {0,0,0,0,0,1,1,1,1,0}, {0,0,1,0,0,0,0,0,1,0}, {0,1,1,1,1,0,0,0,1,0}, {0,1,1,1,1,0,0,0,1,0}, {0,0,0,0,1,1,1,1,1,0}, {0,0,0,0,0,0,0,0,0,0}, }; const v[4]={0,1,0,-1}; const h[4]={1,0,-1,0}; short f[10][10]={0}; short mark[10][10]={0};
1