Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
高手们帮我看下怎么是wrong answer#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator