题解
2024-08-06 20:34:56
发布于:四川
11阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int N = 100 + 10;
struct Student{
string name;
int id;
int ch;
int ma;
};
int main(){
int n, m;
Student a[N];
cin >> n >> m;
for(int i = 0;i < n;i++){
cin >> a[i].name >> a[i].id >> a[i].ch
>> a[i].ma;
}
for(int i = 0;i < m;i++){
string user;
cin >> user;
if(user == "name"){
string user_name;
cin >> user_name;
for(int i = 0;i < n;i++){
if(a[i].name == user_name){
printf("%d %d\n", a[i].ch, a[i].ma);
break;
}
}
}
else{
int user_id;
cin >> user_id;
for(int i = 0;i < n;i++){
if(a[i].id == user_id){
printf("%.2lf\n", (a[i].ch + a[i].ma) / 2.0);
break;
}
}
}
}
return 0;
}
这里空空如也
有帮助,赞一个