动态规划之最短距离

#include
#define N 100
#define MAXV 1000000
using namespace std;
/*
city[i][j]代表从城市i到城市j的花费 
10
0 5 6 7 0 0 0 0 0 0
0 0 0 0 1 2 0 0 0 0
0 0 0 0 3 6 7 0 0 0
0 0 0 0 0 2 6 0 0 0
0 0 0 0 0 0 0 7 0 0
0 0 0 0 0 0 0 5 3 0
0 0 0 0 0 0 0 2 0 0
0 0 0 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 0 6
0 0 0 0 0 0 0 0 0 0
*/
int city[N][N];
//打印路线图 
void print(int n){
	if(n==0){
		cout<=0;i--){
		if(city[i][n]==0) continue;
		int cost = city[0][n]-city[0][i];
		if(cost==city[i][n]) break;
	}
	fun(i);
	cout<<"->"<>n;
	for(int i=0;i>city[i][j];
		}
	}
	//计算从城市0到城市i的最小花费 
	for(int i=1;i


 

你可能感兴趣的:(动态规划之最短距离)