1 个赞
100分
2 个赞
AC 代码,这个都看得懂的:
#include<bits/stdc++.h>
using namespace std;
string ans[15];int k=0;
int n,m;double x;
double restaurant(double a,double b,double c,double d,double e){
cin>>a>>b>>c>>d>>e;
return a*0.2+b*0.2+c*0.2+d*0.2+e*0.2;
}
double scene(double a,double b,double c){
cin>>a>>b>>c;
return a*0.3+b*0.3+c*0.4;
}
double snacks(double a,double b,double c,double d){
cin>>a>>b>>c>>d;
return a*0.2+b*0.3+c*0.2+d*0.3;
}
int main(){
//freopen("cityscore3.in","r",stdin);
//freopen("cityscore3.out","w",stdout);
cin>>n>>x;
for(int i=1;i<=n;i++){
string name;
cin>>name;
cin>>m;
double sum=0;
for(int j=1;j<=m;j++){
string s;
cin>>s;
if(s=="restaurant"){
sum+=restaurant(0,0,0,0,0);
}
if(s=="scene"){
sum+=scene(0,0,0);
}
if(s=="snacks"){
sum+=snacks(0,0,0,0);
}
}
cout<<name<<" ";printf("%0.3lf\n",sum/m);
if(sum/m>x){
k++;
ans[k]=name;
}
}
for(int i=1;i<=k;i++)cout<<ans[i]<<" ";
if(k==0)cout<<"sad"<<endl;
return 0;
}
这个不是题目的 AC 代码,是自己出的题的题解!!!!!
2 个赞