社区讨论

P5728求助!!!为啥没输出???

题目总版参与者 4已保存回复 5

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
5 条
当前快照
1 份
快照标识符
@lzwni9cl
此快照首次捕获于
2024/08/16 19:53
2 年前
此快照最后确认于
2024/08/16 22:02
2 年前
查看原帖
题目:P5728旗鼓相当的对手
CPP
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;
}

回复

5 条回复,欢迎继续交流。

正在加载回复...