P5740求解惑

P5740 【深基7.例9】最厉害的学生

@[chy2002](/user/735073) 可以参考一下 ```cpp #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstring> using namespace std; struct stu1{ char name[50]={0}; int c=0; int m=0; int y=0; }; bool jug1(int a1,int b1,int c1,int a2,int b2,int c2){ bool y; if((a1+b1+c1)>(a2+b2+c2)){ y=true; return y; } else{ y=false; return y; } } int main(){ int n; cin>>n; stu1 a[n],d; for(int i=0;i<n;i++){ cin>>a[i].name>>a[i].c>>a[i].m>>a[i].y; } strcpy(d.name,a[0].name); d.c=a[0].c; d.m=a[0].m; d.y=a[0].y; for(int i=0;i<n;i++){ if(jug1(a[i].c,a[i].m,a[i].y,d.c,d.m,d.y)){ strcpy(d.name,a[i].name); d.c=a[i].c; d.m=a[i].m; d.y=a[i].y; } } cout<<d.name<<" "<<d.c<<" "<<d.m<<" "<<d.y; return 0; } ```
by sto_OwenLMZ2022_orz @ 2022-06-03 17:42:06


@[OwenLMZ2022](/user/691282) 谢谢了,我知道是哪里的问题了
by chy2002 @ 2022-06-05 17:36:24


|