Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

FT 题目看错了

Posted by JUSTACCEPTED at 2007-05-17 11:33:02 on Problem 1603
In Reply To:达人帮我看看这个程序错在哪??实在不知哪有bug。 Posted by:JUSTACCEPTED at 2007-05-16 22:48:12
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator