P5728求助!!!为啥没输出???
  • 板块题目总版
  • 楼主hi_huangbx
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/8/16 19:53
  • 上次更新2024/8/16 22:02:47
查看原帖
P5728求助!!!为啥没输出???
1023424
hi_huangbx楼主2024/8/16 19:53

题目:P5728旗鼓相当的对手

using namespace std;
int cnt=0;
bool s=false,t=false;
struct peo{
    int num;
    int chi;
    int mat;
    int eng;
    int tot;
};
struct peo peo[4];
void single(int a,int b) {
    if((peo[a].chi-peo[b].chi)>=0 ||(peo[a].chi-peo[b].chi)<=5) {
        if((peo[a].mat-peo[b].mat)>=0 ||(peo[a].mat-peo[b].mat)<=5) {
            if((peo[a].eng-peo[b].eng)>=0 ||(peo[a].eng-peo[b].eng)<=5) {
               s=true;
            }
        }
    }
}
void total(int c,int d) {
    if((peo[c].tot-peo[d].tot)>=0 ||(peo[c].tot-peo[d].tot)<=5) {
        t=true;
    }
}
int main() {
    int t;
    cin>>t;
    for(int i=1;i<=t;i++) {
        cin>>peo[i].num>>peo[i].chi>>peo[i].mat>>peo[i].eng;
        peo[i].tot=peo[i].chi+peo[i].mat+peo[i].eng;
    }
    for(int i=1;i<=t;i++) {
        for(int j=1;j<=t;i++) {
            single(i,j);
            total(i,j);
            if(s==true || t==true) {
                cnt++;
            }
        }
    }
    cout<<cnt;
}
2024/8/16 19:53
加载中...