样例可过但全部WA……求看下哪错了……

#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

struct STU
{
    string name;
    int score;
    int rating;
    char isWorker;
    char isWestern;
    int pub;
    int scholar;
    
    void calcScholar()
    {
        scholar = (score > 80 and pub > 0?          8000: 0)
                + (score > 85 and rating > 80?      4000: 0)
                + (score > 90?                      2000: 0)
                + (score > 85 and isWestern == 'Y'? 1000: 0)
                + (rating > 80 and isWorker == 'Y'?  850: 0);
    }
};

bool cmp(STU l, STU r)
{
    return (l.scholar = r.scholar? l.name < r.name: l.scholar < r.scholar);
}

istream &operator>>(istream &in, STU &s)
{
    in >> s.name >> s.score >> s.rating >> s.isWorker >> s.isWestern >> s.pub;
    s.calcScholar();
    return in;
}

ostream &operator<<(ostream &out, STU &s)
{
    out << s.name << endl << s.scholar;
    return out;                                                                                                                                                                                                                                                                                                 
}

int main()
{
    int size, sum = 0;
    cin >> size;
    const int SIZE = size;
    STU student[SIZE];
    for (int i = 0; i < SIZE; i ++)
    {
        cin >> student[i];
        sum += student[i].scholar;
    }
    sort(student, student + SIZE, cmp);
    cout << student[0] << endl << sum << endl; 
    return 0;
}

1 条评论

  • @ 2016-04-02 17:53:47

    bool cmp(STU l, STU r)
    {
    return (l.scholar = r.scholar? l.name < r.name: l.scholar < r.scholar);
    ^ ...?

  • 1

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
39038
已通过
12700
通过率
33%
被复制
120
上传者