题解
2024-09-02 22:22:24
发布于:广东
7阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct stu{
string name;
int stu_number;
int stu_Chinese;
int stu_Maths;
}a[100001];
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>a[i].name>>a[i].stu_number>>a[i].stu_Chinese>>a[i].stu_Maths;
}
for(int i=1;i<=m;i++)
{
string pd_name;
cin>>pd_name;
if(pd_name=="name")
{
string pd_mz;
cin>>pd_mz;
for(int i=1;i<=n;i++)
{
if(pd_mz==a[i].name)
{
cout<<a[i].stu_Chinese<<" "<<a[i].stu_Maths<<endl;
break;
}
}
}
else{
int x;
cin>>x;
for(int i=1;i<=n;++i)
{
if(x==a[i].stu_number)
{
cout<<fixed<<setprecision(2)<<(a[i].stu_Chinese+a[i].stu_Maths)/2.0<<endl;
break;
}
}
}
}
}
这里空空如也
有帮助,赞一个