额,我用别的方法写了下,但是感觉思路很乱,有没有大佬帮忙加下注释
#include<bits/stdc++.h>
using namespace std;
const int sad=8;
int last=-1e6;
class Jin{
public:
int school,home,lans;
int today(void);
bool son(Jin an,int n);
friend void ans(Jin a);
};
Jin a;
int Jin::today(void){
return school+home;
}
bool son(Jin an){
if(an.today()>sad) return true;
return false;
}
void ans(Jin al,int n){
if(al.today()>last && son(al)) {
last=al.today();
a.lans=n;
}
}
int main(){
for(int i=1;i<=7;i++){
cin>>a.school>>a.home;
ans(a,i);
}
cout<<a.lans<<endl;
return 0;
}