大佬求助哪里有问题

UVA10048 Audiophobia

AndyChen2005121 @ 2019-07-17 14:22:38

#include <iostream>
#include <cstring>
using namespace std;
int c, s, q, kase = 1;
int g[105][105];
const int INF = 0x3f3f3f3f;
void floyd(int n){
    for(int k = 0; k < n; k++){
        for(int x = 0; x < n; x++){
            for(int y = 0; y < n; y++){
                g[x][y] = max(g[x][y], min(g[x][k], g[k][y]));
            }
        }
    }
}
int main() {
    while(cin >> c >> s >> q && c != 0 && s != 0 && q != 0){
        memset(g, INF, sizeof(g));
        for(int i = 0; i < c; i++){
            g[i][i] = 0;
        }
        for(int i = 0; i < s; i++){
            int c1, c2, d;
            cin >> c1 >> c2 >> d;
            g[c1][c2] = g[c2][c1] = d;
        }
        floyd(c);
        cout << "Case #" << kase++ << endl;
        for(int i = 0; i < q; i++){
            int c1, c2;
            cin >> c1 >> c2;
            if(g[c1][c2] == INF){
                cout << "no path" << endl;          
            } else {
                cout << g[c1][c2] << endl;
            }
        }
    }
}

|