| ||||||||||
| 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 把你的数组开大点,In Reply To:不知道为什么,就是WA,请大牛们指教一下。 Posted by:hairlun at 2007-12-22 11:11:05 #include<stdio.h>
int main()
{ int i,j,t,f,r,p,a[12],b[12];
float c[150],max,m;
while(1)
{ scanf("%d",&f);
if(f==0) break;
scanf("%d",&r);
for(i=0;i<f;i++) scanf("%d",&a[i]);
for(i=0;i<r;i++) scanf("%d",&b[i]);
t=-1;
for(i=0;i<f;i++)
for(j=0;j<r;j++)
{ t++;
c[t]=(float)b[j]/a[i];
}
for(i=0;i<t;i++)
{ p=0;
for(j=0;j<t-i;j++)
if(c[j]<c[j+1])
{ p++;
m=c[j];
c[j]=c[j+1];
c[j+1]=m;
}
if(p=0) break;
}
max=0;
for(i=0;i<t;i++)
if(max<c[i]/c[i+1]) max=c[i]/c[i+1];
printf("%.2f\n",max);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator