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 |
哪 位牛人可以帮帮小弟看一看是什么错误啊,十分感激!!!!!#include<stdio.h> #include<malloc.h> void main() { int cas,M,*floor,a,b,i=0,j=0,mark; double sum,min=10000000; scanf("%d",&cas); for(i=1;i<=cas;i++) { min=1000000; scanf("%d%d%d",&M,&a,&b); floor=(int *)malloc((M+1)*sizeof(int)); for(i=1;i<=M;i++) scanf("%d",&floor[i]); for(i=1;i<=M;i++) { sum=0; for(j=1;j<=M-i;j++) { sum+=floor[i+j]*(a*j+0.5*j*(j-1)); } for(j=1;j<=i-1;j++) { sum+=floor[i-j]*(b*j+0.5*j*(j-1)); } if(min>sum) { mark=i; min=sum; } } printf("%d\n",mark); free(floor); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator