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 |
怎么总是WA啊?路过的大牛们帮帮忙看一下啊。。。先谢谢了,,,,#include<iostream> #include<iomanip> using namespace std; #include<stdlib.h> int cmp(const void*x,const void*y) { return *(float*)x-*(float*)y; } int main() { int front,rear,snum; while(cin>>front&&front!=0) { cin>>rear; int*f,*r; f=new int[front]; r=new int[rear]; int i,j; for(i=0;i<front;i++) cin>>f[i]; for(i=0;i<rear;i++) cin>>r[i]; float*a,*b; snum=front*rear; a=new float[snum]; b=new float[snum-1]; for(i=0;i<front;i++) for(j=0;j<rear;j++) a[rear*i+j]=r[j]*1.0/f[i]; qsort(a,snum,sizeof(float),cmp); for(i=0;i<snum-1;i++) b[i]=a[i+1]/a[i]; float max=0; for(i=0;i<snum-1;i++) if(b[i]>max) max=b[i]; cout<<setprecision(2)<<setiosflags(ios::fixed)<<max<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator