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 |
为什么runtime error ?结果都对啊!大牛们帮我看看吧~~#include<Stdio.h> int up(int a,int n) { return n * a + 0.5 *n * (n - 1) ; } int down(int b,int n) { return n * b + 0.5 * n * (n- 1) ; } void main() {int a,b,i,j,s,t,m,k[100],sum=0,dis,lift; scanf("%d",&t); for(i=0;i<t;i++) {scanf("%d%d%d",&m,&a,&b); for(j=0;j<m;j++){ scanf("%d",&k[j]);} for(j=0;j<m;j++ ){ for(s=0;s<m;s++) {if(s==j) ; else if(s>j) sum+=k[s]*up(a,s-j); else sum+=k[s]*down(b,j-s);} if(j==0||sum<dis) {dis=sum;sum=0;lift=j+1;} }printf("%d\n",lift); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator