sodasne
2024-08-23 12:24:49
发布于:广东
2阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
int n, m;
int dat;
string x;
string nm;
double avg;
struct node{
string name;
int id, c, m;
}a[maxn];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> a[i].name >> a[i].id >> a[i].c >> a[i].m;
}
for(int i = 1; i <= m; i++){
cin >> x;
if(x == "name"){
cin >> nm;
for(int i = 1; i <= n; i++){
if(a[i].name == nm){
cout << a[i].c << ' ' << a[i].m;
cout << endl;
break;
}
}
}else if(x == "number"){
cin >> dat;
for(int i = 1; i <= n; i++){
if(a[i].id == dat){
int sum = a[i].c + a[i].m;
printf("%.2lf", sum * 1.0 / 2);
cout << endl;
break;
}
}
}
}
return 0;
}
这里空空如也
有帮助,赞一个