#include using namespace std; int main(){ int a,b,x=8,n; bool flag=true; for(int i=1;i<=7;i++){ cin>>a>>b; if(a+b>x){ n=i; x=a+b; flag=false; } } if(flag){ cout<<0; } else{ cout<<n; } return 0; }
#include using namespace std;
int main() { int a[7]; int max = -1; int day = 1; for (int i = 0; i <7 ; ++i) { int t; cin>>a[i]; cin>>t; a[i] += t; if (a[i]>max){ max = a[i]; day = i+1; } } cout<<day; return 0; }
共 2 条回复
#include using namespace std;
int main() { int a[7]; int max = -1; int day = 1; for (int i = 0; i <7 ; ++i) { int t; cin>>a[i]; cin>>t; a[i] += t; if (a[i]>max){ max = a[i]; day = i+1; } } cout<<day; return 0; }
#include using namespace std; int main(){ int a,b,x=8,n; bool flag=true; for(int i=1;i<=7;i++){ cin>>a>>b; if(a+b>x){ n=i; x=a+b; flag=false; } } if(flag){ cout<<0; } else{ cout<<n; } return 0; }