注意要保留两位小数诶
2024-12-02 09:28:13
发布于:河南
2阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
struct stu{
string name;
int id;
int ch;
int math;
};
int main()
{
int n,m;
cin>>n>>m;
stu a[n];
for(int i=0;i<n;i++){
cin>>a[i].name>>a[i].id>>a[i].ch>>a[i].math;
}
string action;
int t=1;
while(t<=m){
cin>>action;
if(action == "name"){
string x;
cin>>x;
for(int i=0;i<n;i++){
if(a[i].name == x){
cout<<a[i].ch<<" "<<a[i].math<<endl;
}
}
}else if(action == "number"){
int y;
cin>>y;
for(int i=0;i<n;i++){
if(a[i].id == y){
double re;
re = (a[i].ch+a[i].math)/2.00;
cout<<fixed<<setprecision(2)<<re<<endl;
}
}
}
t++;
}
return 0;
}
这里空空如也
有帮助,赞一个