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

各位高手看看,下面的程序哪里错了?

Posted by szh992 at 2006-09-23 16:28:33 on Problem 1926
#include <stdio.h>
#include <math.h>
int n,m, adjacent[101][101],tankadjnum[101],isnoadj[101],exitt=0;
double tank[101],oldtank[101];
void timet1()
{
  int i,j;
  while(1){
  for(i=1;i<=n;i++){
	  tank[i]=0;
	  for(j=1;j<=n;j++)
	  {
         if(j!=i)
		 {
			 if(tankadjnum[j]!=0)
			    tank[i]+=adjacent[i][j]*oldtank[j]/tankadjnum[j];
		     //printf("tank[%d]=%f\n",i,tank[i]);
		 }
	  }
	  if(isnoadj[i]==0)
		  tank[i]=oldtank[i];
  }
  exitt=1;
  for(i=1;i<=n;i++)
	  if((tank[i]-oldtank[i]>=0?tank[i]-oldtank[i]:oldtank[i]-tank[i])>=0.001)
		  exitt=0;
  if(exitt==1)
  {
	  for(i=1;i<=n;i++)
		  printf("%.3f\n",tank[i]);
	  printf("\n");
	  return;
  }
  for(i=1;i<=n;i++)
	   oldtank[i]=tank[i];
  }
}
int main()
{
	int t,i,j,k,a,b;
	scanf("%d",&t);
    for(k=1;k<=t;k++)
	{
	 	for(i=1;i<=100;i++)
		{   
		tankadjnum[i]=0;
		isnoadj[i]=0;
		for(j=1;j<=100;j++)
	    	adjacent[i][j]=0;
		}
		scanf("%d%d",&n,&m);
        for(j=1;j<=n;j++)
		{scanf("%lf",&tank[j]);
		 oldtank[j]=tank[j];
		}
        for(j=1;j<=m;j++)
		{
			scanf("%d%d",&a,&b);
			adjacent[a][b]=1;
			adjacent[b][a]=1;
			tankadjnum[a]+=1;
			tankadjnum[b]+=1;
			isnoadj[a]=1;
			isnoadj[b]=1;
		}
        timet1();
	}
	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