样例过了,但是全WA,求助(C++)
查看原帖
样例过了,但是全WA,求助(C++)
575863
yuxuanctgzs楼主2022/10/3 21:07

直接上代码:

#include<iostream>
#include<string>
#include<cmath>
using namespace std;
struct node
{
    string name;
    int c,m,e,t;
};
node student[1009];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>student[i].name;
        cin>>student[i].c>>student[i].m>>student[i].e;
        student[i].t=student[i].c+student[i].m+student[i].e;
    }
    for(int l=2;l<=n;l++)
    {
        for(int p=1;p<=n-1;p++)
        {
            if(p==l)
            {
                continue;
            }
            else
            {
                if(abs(student[p].c-student[l].c)<=5&&abs(student[p].m-student[l].m)<=5&&abs(student[p].e-student[l].e)<=5&&abs(student[p].t-student[l].t)<=10)
                {
                   if(student[p].name[1]>student[l].name[1])
                   {
                       cout<<student[p].name<<" "<<student[l].name<<endl;
                   }
                   else
                   {
                       if(student[p].name[1]>student[l].name[1])
                       {
                           cout<<student[p].name<<" "<<student[l].name<<endl;
                       }
                       else
                       {
                           if(student[p].name[2]>student[l].name[2])
                           {
                               cout<<student[l].name<<" "<<student[p].name<<endl;
                           }
                           else
                           {
                             if(student[p].name[2]<student[l].name[2])
                             {
                                cout<<student[p].name<<" "<<student[l].name<<endl;
                             }
                           }
                       }
                   }
               }

           }
        }
     }
}

求助

2022/10/3 21:07
加载中...