@[hezhen2009](/user/381681) ||
- 函数中改变值是不会改变实值。需要取地址,或者开成全局变量。
- 局部变量没有初始化
by JK_LOVER @ 2020-09-13 13:54:43
@[hezhen2009](/user/381681) ||
```cpp
#include<bits/stdc++.h>
using namespace std;
struct student{
string name;
int C,M,E;
};
void bi(student &a,student b){
if(a.C+a.E+a.M<b.C+b.E+b.M){
a.name=b.name;
a.C=b.C;a.E=b.E;a.M=b.M;
}
}
int main(void){
int N;
scanf("%d",&N);
student best ={"0",0,0,0};
for(int i=1;i<=N;i++){
student stu;
cin>>stu.name>>stu.C>>stu.M>>stu.E;
bi(best,stu);
}
cout<<best.name<<" "<<best.C<<" "<<best.M<<" "<<best.E<<endl;
return 0;
}
```
by JK_LOVER @ 2020-09-13 13:55:13
@[JK_LOVER](/user/227824)
感谢dalao
by Hz138588 @ 2020-09-13 14:01:05