Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
达人帮我看看这个程序错在哪??实在不知哪有bug。#include<stdio.h> #define INF 1000 int map[21][21] ; void floyd( ) { int u , v , w ; for( u = 1 ; u <= 20 ; u++ ) { for( v = 1 ; v <= 20 ; v++ ) { for( w = 1 ; w <= 20 ; w++ ) { if( map[v][u] + map[u][w] < map[v][w] ) { map[v][w] = map[v][u] + map[u][w] ; } } } } } int main() { int i , k , v, vn , T , u ; for( i = 1 ; i <= 20 ; i++ ) { for( k = 1 ; k <= 20 ; k++ ) { map[i][k] = INF ; } } for( i = 1 ; i <= 19 ; i++ ) { scanf("%d" , &vn ) ; for( k = 1 ; k <= vn ; k++ ) { scanf("%d" , &v ) ; map[i][v] = 1 ; map[v][i] = 1 ; } } floyd( ) ; for( k = 1 ; scanf("%d" , &T ) != EOF ; k++ ) { printf("Test Set #%d\n" , k ) ; for( i = 1 ; i <= T ; i++ ) { scanf("%d%d" , &u , &v ) ; printf("%d to %d: %d\n" , u , v , map[u][v] ) ; } printf("\n") ; } return 0 ; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator