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 <string> #include <cmath> #include <iomanip> #include <vector> using namespace std; class Ranking { public: char name[10]; double sum,t[7]; int count,rank,ave_time; Ranking () { sum=0; count=0; rank=0; } void OutPut() { if (rank<10) cout<<"0"<<rank<<" "; else cout<<rank<<" "; cout<<left<<setw(10)<<name<<" "; cout<<count<<" "; cout<<right<<setw(4)<<sum<<" "; cout<<setw(3)<<ave_time<<" "; for (int m=0;m<7;m++) cout<<setw(3)<<t[m]<<" "; cout<<endl; } }; Ranking Teams[20]; void Judge(int R) { if ((Teams[R].count==Teams[R-1].count)&&(Teams[R].sum==Teams[R-1].sum) &&(Teams[R].ave_time==Teams[R-1].ave_time)) Teams[R].rank=Teams[R-1].rank; } int main () { int n,i,j,m=1; double Sum=0; cin>>n; while (n!=0) { for (i=0;i<n;i++) { cin>>Teams[i].name; for (j=0;j<7;j++) { cin>>Teams[i].t[j]; if (Teams[i].t[j]!=0) { Teams[i].count++; Sum+=log(Teams[i].t[j]); } Teams[i].sum+=Teams[i].t[j]; } if (Teams[i].count!=0) Teams[i].ave_time=exp(Sum/Teams[i].count)+0.5; else Teams[i].ave_time=0; Sum=0; } for (i=0;i<n;i++) { for (j=i;j<n;j++) { if (Teams[i].count<Teams[j].count) swap(Teams[i],Teams[j]); else if ((Teams[i].count==Teams[j].count) &&(Teams[i].sum<Teams[j].sum)) swap(Teams[i],Teams[j]); else if ((Teams[i].count==Teams[j].count) &&(Teams[i].sum==Teams[j].sum) &&(Teams[i].ave_time>Teams[j].ave_time)) swap(Teams[i],Teams[j]); else if ((Teams[i].count==Teams[j].count) &&(Teams[i].sum==Teams[j].sum) &&(Teams[i].ave_time==Teams[j].ave_time) &&Teams[i].name[0]>Teams[j].name[0]) swap(Teams[i],Teams[j]); } } cout<<"CONTEST "<<m<<endl; for (i=0;i<n;i++) { Teams[i].rank=i+1; if (i>0) Judge(i); Teams[i].OutPut(); } memset(Teams,0,sizeof(Teams)); cin>>n; m++; } system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator