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

Re:哪里出问题了,帮帮忙呀,我实在是找不出来啦!!!!!

Posted by d2d2 at 2006-10-16 00:37:55 on Problem 2017
In Reply To:哪里出问题了,帮帮忙呀,我实在是找不出来啦!!!!! Posted by:00430030 at 2005-01-10 16:20:37
#include<stdio.h>
#include<math.h>
void main ()
{
    int  n,a[20],b[20],i,sum=0,j;
	for(;;)	
{	scanf("%d",&n);
    if(n==-1)  goto end;    
	for(i=0;i<n;i++)
			scanf("%d %d",&a[i],&b[i]);
	
		if(n==1)  printf("%d miles\n",a[0]*b[0]);
		else  
{       sum=a[0]*b[0];
		for(j=1;j<n;j++)    
		sum=sum+a[j]*(b[j]-b[j-1]);
		printf("%d miles\n",sum);
	}
}
end:;
}

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