📄 1224.cpp
字号:
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<string>
#include<vector>
#include<iomanip>
using namespace std;
class item{
public:
string name;
double hit,kill,err,block,dig,hitrate,c;
item(string a){
name=a;
hit=kill=err=block=dig=0;
c=1;
}
};
int cmp(const item & a,const item & b){
return a.name<b.name;
}
int main(){
//ifstream cin("in.txt");
//ofstream cout("out.txt");
string s1,s2;
vector<item> vec;
int i,j,k,n,c=0;
while(cin>>s1){
if(s1=="R"){
sort(vec.begin(),vec.end(),cmp);
cout<<"Player Hit Pct KPG BPG DPG\n-----------------------------------------\n";
double hit=0,kpg=0,bpg=0,dpg=0,err=0;
for(i=0;i<vec.size();i++){
if((vec[i].kill+vec[i].err+vec[i].hit)==0) vec[i].hitrate=0;
else vec[i].hitrate=(vec[i].kill-vec[i].err)/(vec[i].kill+vec[i].err+vec[i].hit);
cout<<vec[i].name<<" ";
if(vec[i].hitrate>=0) cout<<"+"<<setiosflags(ios::fixed)<<setprecision(3)<<vec[i].hitrate;
else cout<<setiosflags(ios::fixed)<<setprecision(3)<<vec[i].hitrate;
cout<<setiosflags(ios::fixed)<<setprecision(3)<<" "<<setiosflags(ios::right)<<setw(6)<<vec[i].kill/vec[i].c<<" "<<setw(6)<<vec[i].block/vec[i].c<<" "<<setw(6)<<vec[i].dig/vec[i].c<<endl;
hit+=vec[i].hit;kpg+=vec[i].kill;bpg+=vec[i].block;dpg+=vec[i].dig;err+=vec[i].err;
}
cout<<"team ";
double hitrate;
if(kpg+err+hit==0) hitrate=0;
else hitrate=(kpg-err)/(kpg+err+hit);
if(hitrate>=0) cout<<"+"<<setiosflags(ios::fixed)<<setprecision(3)<<hitrate;
else cout<<setiosflags(ios::fixed)<<setprecision(3)<<hitrate;
cout<<setiosflags(ios::fixed)<<setprecision(3)<<" "<<setiosflags(ios::right)<<setw(6)<<kpg/c<<" "<<setw(6)<<bpg/c<<" "<<setw(6)<<dpg/c<<endl;
vec.clear();
c=0;
cout<<endl;
continue;
}
if(s1=="C"){
c+=1;
getline(cin,s2);
istringstream is(s2);
is>>n;
while(is>>s1){
for(i=0;i<vec.size();i++) if(vec[i].name==s1) break;
if(i==vec.size())
vec.push_back(item(s1));
else vec[i].c+=1;
}
continue;
}
else{
cin>>s2;
for(i=0;i<vec.size();i++){
if(s2==vec[i].name){
if(s1=="H") vec[i].hit+=1;
else if(s1=="K") vec[i].kill+=1;
else if(s1=="E") vec[i].err+=1;
else if(s1=="B") vec[i].block+=1;
else if(s1=="D") vec[i].dig+=1;
}
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -