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

为啥会是Wa呢?结果是最大值和最小值之差的两倍啊,给的测试数据也没错啊。求大牛帮帮 忙,小弟拜谢!

Posted by 597503076 at 2008-12-24 18:16:34 on Problem 3632
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int n;
	int i;
	int m;
	int h;
	int j;
	int k;
	int max1[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	int min1[20]={100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};
	int s[20]={0};


	scanf("%d",&h);

	for(j=0;j<h;j++)
	{
	

		n=0;
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&m);
			if(m<min1[j])
			{
				min1[j]=m;
			}
			else if(m>max1[j])
			{
				max1[j]=m;
			}
		}
		s[j]=2*(max1[j]-min1[j]);
		printf("%d\n",s[j]);

	}
	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