</pre><pre name="code" class="cpp"><span style="font-family: Arial, Helvetica, sans-serif;">#include<stdlib.h></span>
#include<stdio.h>
#include "stack"
#include "iostream"
using namespace std;
#define x 9999
#define max 9999
int dist[10];//记录最短路径为多少
int path[10];//记录最短路径
void fpath(int a[][10]);
int froute(int a[][10]);
void main()
{
stack<int> st;
int i,m;
int a[10][10]={
{x,4,2,3,x,x,x,x,x,x},
{x,x,x,x,10,9,x,x,x,x},
{x,x,x,x,6,7,10,x,x,x},
{x,x,x,x,x,3,8,x,x,x},
{x,x,x,x,x,x,x,4,8,x},
{x,x,x,x,x,x,x,9,6,x},
{x,x,x,x,x,x,x,5,4,x},
{x,x,x,x,x,x,x,x,x,8},
{x,x,x,x,x,x,x,x,x,4},
{x,x,x,x,x,x,x,x,x,x}};
fpath(a);
printf("最短路径大小为: %d\n",dist[9]);
int end =9;
while(end>0)
{
st.push(end+1);
end =path[end];
}