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:一直WA,不知道哪里错了,路过的大牛帮忙指点下,谢谢In Reply To:一直WA,不知道哪里错了,路过的大牛帮忙指点下,谢谢 Posted by:inthinker at 2007-07-29 08:58:02 先说一声,在下不是吃草的…… 您那两个vector不应该定义在while循环外,除非每次运行完进行清空操作,否则里面会残留上一组数据的…… > #include<iostream> > #include<vector> > #include<algorithm> > using namespace std; > > int main() > { > int front,rear; > double a[10],b[10]; > int i,j; > vector<double> v; > vector<double> v2; > while(1){ > cin>>front; > if(front==0)return 0; > cin>>rear; > for(i=0;i<front;i++) > cin>>a[i]; > for(j=0;j<rear;j++) > cin>>b[j]; > for(i=0;i<front;i++){ > for(j=0;j<rear;j++){ > double temp; > temp=b[j]/a[i]; > v.push_back(temp); > } > } > sort(v.begin(),v.end()); > > vector<double>::iterator it; > for(it=v.begin()+1;it!=v.end();it++){ > double temp2; > double t1,t2; > t1=*it; > t2=*(it-1); > temp2=t1/t2; > v2.push_back(temp2); > } > sort(v2.begin(),v2.end()); > > printf("%.2f\n",*(v2.end()-1)); > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator