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

你的a[]是不是应该开到1000以上?

Posted by xiedi at 2007-08-03 16:01:54 on Problem 2350
In Reply To:居然有 runtime error ?高手给点提示 Posted by:neverend at 2007-08-03 00:33:57
> #include"iostream"
> using namespace std;
> int main()
> {
>     int i=0,n,count=0,m,j;
> 	float sum,ave,a[100];
> 	scanf("%d",&n);
> 	while(i<n)
> 	{
> 		count=0;sum=0;
> 		i++;
> 		scanf("%d",&m);
> 		for( j=0;j<m;j++)
> 		{
> 			scanf("%f",&a[j]);
> 			sum+=a[j];
> 		}
> 		ave=sum/m;
> 		for(j=0;j<m;j++)
> 			if(a[j]>ave)
> 				count++;
> 			printf("%.3f%%\n",(float) count/m*100);
> 	}
> 	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