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

高手们帮我看下怎么是wrong answer

Posted by bike at 2009-07-18 17:09:00 on Problem 3404
#include <stdio.h>
int main(int argc, char *argv[])
{
	int n,a[50],sum=0,i,min,k;
	scanf("%d",&n);
	if(n==1)
	{
	scanf("%d",a[0]);
	sum=a[0];
	}
	if(n==2)
	{
	scanf("%d%d",a[0],a[1]);
	if(a[0]<a[1])
	sum=a[1];
	else
	sum=a[0];
	}
	if(n>=3)
	{
		for(i=0;i<n;i++)
		scanf("%d",&a[i]);
		min=a[0];
		for(i=1;i<n;i++)
		{
			if(min>a[i])
			{
				k=i;
				min=a[i];
				sum=(n-2)*min;
			}
		}
		for(i=0;i<n&&i!=k;i++)
		sum+=a[i];
	}
	printf("%d\n",sum);
		
	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