旧代码 - 最短路 Bellman Ford(邻接表)

/*
PROG:   Bellman Ford
ID  :   ouyangyewei
LANG:   C++
*/
#include 
#include 
#include 

#define onlinejudge

const int maxn = 1004;
const int INF = 0x3F3F3F3F;

int N, M, destination;
int dist[maxn], path[maxn];
struct EDGE
{
    int u, v, w;
}edge[maxn];

void Bellman_Ford( int src )
{
    int i, k;
    for (i=0; i", xx);
    
    return ;
}// dfs

int main()
{
#ifdef onlinejudge
    freopen("E:\\bellman.txt", "r", stdin);
    freopen("E:\\bellman_ans.txt", "w", stdout);
#endif

    int i, j, a, b, c;
    while (~scanf("%d", &N), N!=0)
    {
        M = 0;
        while (~scanf("%d %d %d", &a, &b, &c), a+b+c!=-3)
        {
            edge[M].u=a, edge[M].v=b, edge[M].w=c;
            ++M;
        }// input
        
        Bellman_Ford( 0 );
        
        for (i=1; i3-->2-->1
3     0-->3-->2
5     0-->3
0     0-->3-->2-->1-->4
4     0-->3-->5
3     0-->3-->2-->1-->4-->6  
*/

你可能感兴趣的:([ACM,ICPC])