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

Re:为什么runtime error ?结果都对啊!大牛们帮我看看吧~~

Posted by flouse at 2007-08-07 01:47:43 on Problem 1701
In Reply To:为什么runtime error ?结果都对啊!大牛们帮我看看吧~~ Posted by:RJXY0711 at 2007-07-29 21:58:43
> #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);
> } 
> }

k[100]
数组越界
1〈=M〈=10000

Runtime Error:
 您的程序发生了访问违规,即访问了不属于自己的内存。最常见的原因是数组下标越界。
 

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