| ||||||||||
| 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 | |||||||||
Re:我的程序为什么总是runtime error,在vc上运行没错啊?In Reply To:我的程序为什么总是runtime error,在vc上运行没错啊? Posted by:90401461 at 2004-12-22 21:35:00 > 我的程序为什么总是runtime error,在vc上运行没错啊?
> 请各位强人指点迷津,多谢多谢。
> 程序如下:
> #include <stdio.h>
> #include <malloc.h>
> void main(){
> int n,i,j,max;
> int *length;
> scanf("%d",&n);
> length=(int*)malloc(n*sizeof(int));
> if(!length)return;
> while(n!=0){
> for(i=0;i<n;i++)scanf("%d",&length[i]);
> max=length[0];
> for(i=1;i<n;i++){
> if(length[i]>max)max=length[i];
> }
> int sum=0;
> for(i=0;i<n;i++)sum+=length[i];
> for(j=n;j>=1;j--){
> if(sum%j==0&&sum/j>=max){
> printf("%d\n",sum/j);
> break;
> }
> }
> scanf("%d",&n);
> }
> free(length);
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator