| ||||||||||
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 |
那位大牛帮忙找找问题,我是没辙了,是算法的问题????#include<iostream.h> #include<math.h> struct student { double v; double st; double arr; }; int compare(student a,student b) { if(a.st>b.st&&a.v>b.v) return 1; return 0; } int main() { int n,a,b; cin>>n; while(n!=0&&n>=1&&n<=10000) { student *p=new student[n]; for(int i=0;i<n;i++) { cin>>a>>b; p[i].v=a/3.6; p[i].st=b; p[i].arr=4500/p[i].v+b; } student x; int k; for(i=1;i<=n-1;i++) { k=i-1; for(int j=i;j<=n-1;j++) { if(p[j].arr<p[k].arr) k=j; } if(k!=i-1) { x=p[i-1]; p[i-1]=p[k]; p[k]=x; } } for( i=1;i<n;i++) { if(compare(p[i],p[i-1])) continue; else break; } cout<<ceil(p[i-1].arr)<<endl; cin>>n; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator