Looks like ····················
This algorithm is quite unfamiliar! Continue learning !!!!
++
======================================
++
-------------------------------------------------
======================================
# Include <stdio. h>
# Include <string. h>
# Deprecision MAX 10000000
# Define N 1001
Int a [N] [N], B [N], next [N] [N];
Int n, len;
Void floyd ()
{
Int I, j, k, numeric;
For (I = 1; I <= n; I ++)
For (j = 1; j <= n; j ++)
Next [I] [j] = j;
For (k = 1; k <= n; k ++)
{
For (I = 1; I <= n; I ++)
{
If (I = k | a [I] [k] =-1)
Continue;
For (j = 1; j <= n; j ++)
{
If (a [k] [j] =-1 | I = k | j = k)
Continue;
Signature = a [I] [k] + a [k] [j] + B [k];
If (a [I] [j] =-1 | a [I] [j]> else)
{
A [I] [j] = bytes;
Next [I] [j] = next [I] [k];
}
Else if (a [I] [j] = alias)
{
If (next [I] [j]> next [I] [k])
Next [I] [j] = next [I] [k];
}
}
}
}
}
Void path (int start, int end)
{
If (end = next [start] [end])
Printf ("% d --> % d \ n", start, end );
Else
{
Printf ("% d -->", start );
Path (next [start] [end], end );
}
}
Int main ()
{
Int I, j, start, end;
While (scanf ("% d", & n), n)
{
For (I = 1; I <= n; I ++)
For (j = 1; j <= n; j ++)
A [I] [j] = MAX;
For (I = 1; I <= n; I ++)
For (j = 1; j <= n; j ++)
Scanf ("% d", & a [I] [j]);
For (I = 1; I <= n; I ++)
Scanf ("% d", & B [I]);
Floyd ();
While (scanf ("% d", & start, & end )! = EOF)
{
If (start =-1 | end =-1)
Break;
Printf ("From % d to % d: \ n", start, end );
If (start = end) // note: the output format when the start point and the end point are the same!
Printf ("Path: % d \ n", start );
Else
{
Printf ("Path :");
Path (start, end );
}
Printf ("Total cost: % d \ n", a [start] [end]);
}
}
Return 0;
}