蒟蒻求助,20分代码

P5741 【深基7.例10】旗鼓相当的对手 - 加强版

@eym0325 大佬在吗?
by Sci_8633 @ 2024-01-21 20:17:30


@[zym0325](/user/804115) 求解
by Sci_8633 @ 2024-01-21 20:18:55


```c #include<bits/stdc++.h> using namespace std; int n; struct node{ string name; int chi,math,eng,sum; }p[1005]; int main(){ cin>>n; for(int i=1;i<=n;++i){ cin>>p[i].name>>p[i].chi>>p[i].math>>p[i].eng; p[i].sum+=p[i].chi+p[i].math+p[i].eng; } for(int i=1;i<=n;++i){ for(int j=i+1;j<=n;++j){ if(abs(p[i].chi-p[j].chi)<=5&&abs(p[i].math-p[j].math)<=5&&abs(p[i].eng-p[j].eng)<=5&&abs(p[i].sum-p[j].sum)<=10){ cout<<p[i].name<<' '<<p[j].name<<endl; } } } return 0; } ``` 把`p[j+1].chi` , `q[j+1].math` , `q[j+1].eng` , `q[j+1].sum` 和 `q[j+1].name` 分别改为 `p[j].chi` , `q[j].math` , `q[j].eng` , `q[j].sum` 和 `q[j].name` , 就AC了 亲测
by 20121028LRR @ 2024-01-30 14:14:33


|