446 条题解

  • 25
    @ 2016-12-10 10:15:10
    #include<iostream>
    using namespace std;
    int main()
    {
        string a,g;
        int b,c,f,n,money=0,result=0,sum=0;
        char d,e;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a>>b>>c>>d>>e>>f;
            money=0;
            if(b>80&&f>=1)
            money+=8000;
            if(b>85&&c>80)
            money+=4000;
            if(b>90)
            money+=2000;
            if(b>85&&e=='Y')
            money+=1000;
            if(c>80&&d=='Y')
            money+=850;
            sum+=money;
            if(result<money)
            {
                result=money;
                g=a;
            }
        }
        cout<<g<<endl<<result<<endl<<sum<<endl;
        return 0;
    }
    
  • 4
    @ 2009-04-04 09:45:58

    输入数据时千万要记得 占位符 加空格

    scanf("%s %d %d %c %c %d"

  • 2
    @ 2019-05-26 17:03:48
    #include <cstdio>
    #include <cstdlib>
    #include <cmath>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    int n,maxsum,sum;
    char maxname[30];
    struct data
    {
        char name[30];
        int s1;
        int s2;
        char a[2];
        char b[2];
        int tot;
        int s;
    }
    ;
    data d[110];
    int main()
    {
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
        {
            scanf("%s%d%d%s%s%d",d[i].name,&d[i].s1,&d[i].s2,d[i].a,d[i].b,&d[i].tot);
            if(d[i].s1>80 && d[i].tot)    d[i].s+=8000;
            if(d[i].s1>85 && d[i].s2>80)    d[i].s+=4000;
            if(d[i].s1>90)  d[i].s+=2000;
            if(d[i].s1>85 && d[i].b[0]=='Y')    d[i].s+=1000;
            if(d[i].s2>80 && d[i].a[0]=='Y')    d[i].s+=850;
            if(d[i].s>maxsum)
            {
                
                strcpy(maxname,d[i].name);
                maxsum=d[i].s;
            }
            sum+=d[i].s;
        }
        printf("%s\n%d\n%d\n",maxname,maxsum,sum);
    
        return 0;
    }
    
  • 2
    @ 2019-02-11 18:48:06
    /*
    @createTime 2019.2.10
    @Author YeahQing
    @problemName 谁拿了最多奖学金
    */
    
    //姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,以及发表的论文数
    #include <iostream>
    
    using namespace std;
    
    struct Student {
        char name[20];
        int avgScore;
        int classScore;
        char isLeader[2];
        char isWest[2];
        int publishPaper;
        int totalPrice = 0;
    };
    
    int isMasterPrice(int avgScore, int publishPaper) {
        if (avgScore > 80 && publishPaper > 0) {
            return 1;
        }
        else {
            return 0;
        }
    }
    
    int isFFPrice(int avgScore,int classScore) {
        if (avgScore > 85 && classScore > 80) {
            return 1;
        }
        else {
            return 0;
        }
    }
    
    int isScoreExcellent(int avgScore) {
        if (avgScore > 90) {
            return 1;
        }
        else {
            return 0;
        }
    }
    
    int isWestPrice(int avgScore, char *isWest) {
        if (avgScore > 85 && *isWest == 'Y' ) {
            return 1;
        }
        else {
            return 0;
        }
    }
    
    int isClassContribution(int classScore, char *isLeader) {
        if (classScore > 80 && *isLeader == 'Y') {
            return 1;
        }
        else {
            return 0;
        }
    }
    
    int main() {
        Student stu[100],res;
        int n;
        int totalPrice = 0;
        cin >> n;
        for (int i = 0; i < n; i++) {
            cin >> stu[i].name
            >> stu[i].avgScore
            >> stu[i].classScore
            >> stu[i].isLeader
            >> stu[i].isWest
            >> stu[i].publishPaper;
        }
    
        res = stu[0];
    
        for (int i = 0; i < n; i++) {
            if (isMasterPrice(stu[i].avgScore, stu[i].publishPaper) == 1) {
                stu[i].totalPrice += 8000;
            }
            if (isFFPrice(stu[i].avgScore, stu[i].classScore) == 1) {
                stu[i].totalPrice += 4000;
            }
            if (isScoreExcellent(stu[i].avgScore) == 1) {
                stu[i].totalPrice += 2000;
            }
            if (isWestPrice(stu[i].avgScore, stu[i].isWest) == 1) {
                stu[i].totalPrice += 1000;
            }
            if (isClassContribution(stu[i].classScore, stu[i].isLeader) == 1) {
                stu[i].totalPrice += 850;
            }
            totalPrice += stu[i].totalPrice;
            if (res.totalPrice < stu[i].totalPrice) {
                res = stu[i];
            }
        }
        
        cout << res.name << '\n'
            << res.totalPrice << '\n'
            << totalPrice;
        
    
        return 0;
    }
    
  • 1
    @ 2019-08-18 15:02:51

    分析一下思路:
    1. 输入各类数据
    2. 算出每个人的奖金数,注意,在算的时候要使用if-if,不能使用if-else if - else结构,因为每个人都可以领多个奖学金,所以有些人符合多个条件
    3. 遍历数组,寻找最多奖学金,求出全部奖金和
    4. 输出有最多奖学金的人,最多的奖学金,以及总共奖学金

    /*
        @createTime 2019.2.10
        @Author C++语言学习者青云
        @problemName 谁拿了最多奖学金
    */
    #include <iostream>
    using namespace std;
    
    int main()
    {
        
        int a;
        cin >> a;
        string name[a];
        int score[a];
        int pingyi[a];
        char ganbu[a];
        char xibu[a];
        int lunwen[a];
        int money[a];
        int w = 0,maxmoney = 0,allmoney = 0;
        for(int i = 0;i < a;i++)
        {
            cin >> name[i] >> score[i] >> pingyi[i] >> ganbu[i] >> xibu[i] >> lunwen[i];
        }
        for(int i = 0;i < a;i++)
        {
            money[i] = 0;
            if(score[i] > 80 && lunwen[i] >= 1)
            {
                money[i] += 8000;
            }
            if(score[i] > 85 && pingyi[i] > 80)
            {
                money[i] += 4000;
            }
            if(score[i]> 90)
            {
                money[i] += 2000;
            }
            if(score[i] > 85 && xibu[i] == 'Y')
            {
                money[i] += 1000;
            }
            if(pingyi[i] > 80 && ganbu[i] == 'Y')
            {
                money[i] += 850;
            }
            allmoney += money[i]; 
        }
        for(int i = 0;i < a;i++)
        {
            if(maxmoney < money[i])
            {
                maxmoney = money[i];
                w = i;
            }
        }
        cout << name[w] << endl << maxmoney << endl << allmoney;
        return 0;
    }
    

    一道很不错的模拟题,祝大家全部AC
    最后吐槽一句:这是什么学校?发这么多奖学金?

  • 1
    @ 2019-06-06 10:36:58
    #include <iostream>
    #include <algorithm>
    using namespace std;
    struct Student{
        string name;
        int endTermScore;
        int classScore;
        bool isCadre;
        bool isWestern;
        int thesisNum;
        int num;
        int scholarship;
        Student(){}
        Student(string na, int es, int cs, char ic, char iw, int tn, int n){
            name = na;
            endTermScore = es;
            classScore = cs;
            isCadre = (ic == 'Y');
            isWestern = (iw == 'Y');
            thesisNum = tn;
            num = n;
            scholarship = 0;
        }
    };
    typedef Student* sp;
    sp students[100];
    int n;
    int sum;
    bool cmp(const sp a, const sp b){
        return a->scholarship == b->scholarship ? a->num < b->num : a->scholarship > b->scholarship;
    }
    void countScholarship(){
        for(int i = 0; i < n; i++){
            sp k = students[i];
            //院士奖学金
            if(k->endTermScore > 80 && k->thesisNum >= 1)
                k->scholarship += 8000;
            
            //五四奖学金
            if(k->endTermScore > 85 && k->classScore > 80)
                k->scholarship += 4000;
            
            //成绩优秀奖
            if(k->endTermScore > 90)
                k->scholarship += 2000;
            
            //西部奖学金
            if(k->endTermScore > 85 && k->isWestern)
                k->scholarship += 1000;
            
            //班级贡献奖
            if(k->classScore > 80 && k->isCadre)
                k->scholarship += 850;
    
            sum += k->scholarship;
        }
    
        sort(students, students + n, cmp);
        return ;
    }
    int main(){
        string na;
        int es, cs, tn;
        char ic, iw;
        cin >> n;
        cin.ignore();
        for(int i = 0; i < n; i++){
            cin >> na >> es >> cs >> ic >> iw >> tn;
            students[i] = new Student(na, es, cs, ic, iw, tn, i); 
        }
        countScholarship();
        cout << students[0]->name << endl;
        cout << students[0]->scholarship << endl;
        cout << sum << endl;
        return 0;
    }
    
    
  • 1
    @ 2019-02-19 15:20:19

    第二次写题解~dalao不要见笑,刚学半年的菜鸟,结构体即可
    上代码:
    #include<iostream>
    #include<cstring>
    #include<string>
    #include<cmath>
    using namespace std;
    struct p
    {
    string n;
    int qimo,pingyi;
    char xibu,ganbu;
    int lunwen;
    long s=0;
    };struct p a[101];
    int main()
    {
    int i,j,n,max=0;
    long long he=0;
    string answer;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>a[i].n>>a[i].qimo>>a[i].pingyi>>a[i].ganbu>>a[i].xibu>>a[i].lunwen;
    if(a[i].qimo>80 and a[i].lunwen>=1)
    a[i].s+=8000;
    if(a[i].qimo>85 and a[i].pingyi>80)
    a[i].s+=4000;
    if(a[i].qimo>90)
    a[i].s+=2000;
    if(a[i].qimo>85 and a[i].xibu=='Y')
    a[i].s+=1000;
    if(a[i].pingyi>80 and a[i].ganbu=='Y')
    a[i].s+=850;
    he+=a[i].s;
    }
    for(i=1;i<n;i++)
    {
    for(j=i+1;j<n;j++)
    {
    if(a[i].s<a[j].s)
    swap(a[i],a[j]);
    }
    }
    cout<<a[1].n<<endl;
    cout<<a[1].s<<endl;
    cout<<he;
    return 0;
    }

    • @ 2019-02-19 19:05:34

      写的好棒,大赞!!!厉害了我的张
      !!!

    • @ 2019-03-11 09:59:33

      @
      cindy201902
      厉害了我的欧阳

  • 1
    @ 2017-07-06 12:18:40

    pascal不哭抱紧我

    type
       Tnode=record
               nam:string;
               adv,cla,num,tot:longint;
               job,west:boolean;
             end;
     var
      st:string;
      N,i,p,q,ans,max:longint;
      a:array[1..100]of Tnode;
      begin
       readln(N);
        max:=0;
        for i:=1 to N do
          begin
            readln(st);
            a[i].job:=false;
            a[i].west:=false;
            p:=pos(' ',st);
            a[i].nam:=copy(st,1,p-1);
            delete(st,1,p);
            p:=pos(' ',st);
            val(copy(st,1,p-1),a[i].adv);
            delete(st,1,p);
            p:=pos(' ',st);
            val(copy(st,1,p-1),a[i].cla);
            delete(st,1,p);
            if st[1]='Y' then a[i].job:=true;
            if st[3]='Y' then a[i].west:=true;
            delete(st,1,4);
            val(st,a[i].num);
            if (a[i].adv>80)and(a[i].num>=1) then inc(a[i].tot,8000);
            if (a[i].adv>85)and(a[i].cla>80) then inc(a[i].tot,4000);
            if a[i].adv>90 then inc(a[i].tot,2000);
            if (a[i].adv>85)and(a[i].west) then inc(a[i].tot,1000);
            if (a[i].cla>80)and(a[i].job) then inc(a[i].tot,850);
            ans:=ans+a[i].tot;
            if a[i].tot>max then
             begin
               max:=a[i].tot;
               q:=i;
             end;
          end;
          writeln(a[q].nam);
          writeln(a[q].tot);
          write(ans);
       end.
    
    
    • @ 2018-01-31 20:22:03

      pascal还有个字符串处理😂

  • 0
    @ 2019-07-23 21:42:39

    '''Python...'''
    x = int(input())
    tot = 0
    top = 0
    for i in range(x):
    y = input().split()
    mo = 0
    mo += 8000 if int(y[1]) > 80 and int(y[5]) > 0 else 0
    mo += 4000 if int(y[1]) > 85 and int(y[2]) > 80 else 0
    mo += 2000 if int(y[1]) > 90 else 0
    mo += 1000 if y[4] == 'Y' and int(y[1]) > 85 else 0
    mo += 850 if int(y[2]) > 80 and y[3] == 'Y' else 0
    tot += mo
    if top < mo:
    top = mo
    name = y[0]
    print(name)
    print(top)
    print(tot)

  • 0
    @ 2019-07-15 20:12:17

    #include<stdio.h>
    #include<math.h>
    #include<string.h>
    typedef struct{
    char name[20];
    int finalscore;
    int classscore;
    char bgb;
    char west;
    int essay;
    int money;
    }S;
    S student[10];
    int main()
    {
    int N,i,flag;
    long sum=0;
    int max=0;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
    scanf("%s %d %d %c %c %d",student[i].name,&student[i].finalscore,&student[i].classscore,&student[i].bgb,&student[i].west,&student[i].essay);
    student[i].money=0;
    }
    for(i=0;i<N;i++)
    {
    if(student[i].finalscore>80&&student[i].essay)
    student[i].money+=8000;
    if(student[i].finalscore>85&&student[i].classscore>80)
    student[i].money+=4000;
    if(student[i].finalscore>90)
    student[i].money+=2000;
    if(student[i].finalscore>85&&student[i].west=='Y')
    student[i].money+=1000;
    if(student[i].classscore>80&&student[i].bgb=='Y')
    student[i].money+=850;
    }
    for(i=0;i<N;i++)
    {
    sum+=student[i].money;
    }
    for(i=0;i<N;i++){
    if(max<student[i].money){
    max=student[i].money;
    flag=i;
    }
    }
    printf("%s\n",student[flag].name);
    printf("%d\n",student[flag].money);
    printf("%d",sum);
    return 0;
    }

  • 0
    @ 2019-06-19 15:59:31

    #include <iostream>
    #include <string>
    using namespace std;
    struct student {
    string name;
    int cj1;
    int cj2;
    int write;
    int money;
    }per[100];
    int main(void)
    {
    int all;
    int i = 0;
    int win = 0;
    unsigned long int all_money = 0;
    char a;
    cin >> all;
    while (i < all) {
    per[i].money = 0;
    cin >> per[i].name;
    cin >> per[i].cj1;
    cin >> per[i].cj2;
    cin >> a;
    if (a == 'Y'&&per[i].cj2 > 80)per[i].money += 850;
    cin >> a;
    if (a == 'Y'&&per[i].cj1 > 85)per[i].money += 1000;
    cin >> per[i].write;
    if (per[i].cj1 > 80 && per[i].write)per[i].money += 8000;
    if (per[i].cj1 > 85 && per[i].cj2 > 80)per[i].money += 4000;
    if (per[i].cj1 > 90)per[i].money += 2000;
    ++i;
    }
    for (i = 0; i < all; ++i) {
    if (per[win].money < per[i].money)win = i;
    all_money += per[i].money;
    }
    cout << per[win].name << endl << per[win].money << endl << all_money;
    return 0;
    }

  • 0
    @ 2019-06-12 20:38:10

    按题意判断即可~
    cpp
    #include <iostream>
    #include <string>
    using namespace std;
    int main()
    {
    string name[101];
    int qimo[101],banji[101];
    char xuesheng[101],xibu[101];
    int lunwen[101];
    int n,ans=0;
    int money;
    int max1=-1;
    string maxstudent;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    money=0;
    cin>>name[i]>>qimo[i]>>banji[i]>>xuesheng[i]>>xibu[i]>>lunwen[i];
    if(qimo[i]>80 && lunwen[i]>=1) money+=8000;
    if(qimo[i]>85 && banji[i]>80) money+=4000;
    if(qimo[i]>90) money+=2000;
    if(qimo[i]>85 && xibu[i]=='Y') money+=1000;
    if(banji[i]>80 && xuesheng[i]=='Y') money+=850;
    ans+=money;
    if(money>max1)
    {
    max1=money;
    maxstudent=name[i];
    }
    }
    cout<<maxstudent<<endl<<max1<<endl<<ans;
    return 0;
    }

  • 0
    @ 2019-06-05 21:59:59
    #include <iostream>
    #include <algorithm>
    #include <cstring>
    #include <string>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    const int N = 110;
    struct code
    {
        string name,work,west;
        int end_mark,class_mark,sum,ans;
    }a[N];
    string high_name;
    int n;
    int ans = 0,all_ans = 0;
    int main()
    {
        cin >> n;
        for(int i = 0; i < n; i++)
        {
            cin >> a[i].name >> a[i].end_mark >> a[i].class_mark >> a[i].work >> a[i].west >> a[i].sum;
            if(a[i].end_mark > 80 && a[i].sum >= 1) a[i].ans += 8000;
            if(a[i].end_mark > 85 && a[i].class_mark > 80)  a[i].ans += 4000;
            if(a[i].end_mark > 90)  a[i].ans += 2000;
            if(a[i].end_mark > 85 && a[i].west == "Y")  a[i].ans += 1000;
            if(a[i].class_mark > 80 && a[i].work == "Y")    a[i].ans += 850;
            if(a[i].ans > ans)
            {
                high_name = a[i].name;
                ans = a[i].ans;
            }
        }
        for(int i = 0; i < n; i++)
        {
            all_ans += a[i].ans;
        }
        cout << high_name << endl << ans << endl << all_ans << endl;
        return 0;
    }
    
  • 0
    @ 2019-05-12 16:15:48

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<string>
    #include<algorithm>
    #include<cmath>
    using namespace std;
    struct node{
    string xm;
    int qm,bj;
    char bgb,xb;
    int lw;
    int ans;
    int sum;
    }a[101];
    int n,tot=0;
    bool cmp(node x,node y)
    {
    if(x.ans==y.ans)return x.sum<y.sum;
    else return x.ans>y.ans;
    }
    int main()
    {
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    cin>>a[i].xm>>a[i].qm>>a[i].bj>>a[i].bgb>>a[i].xb>>a[i].lw;
    if(a[i].qm>80&&a[i].lw>=1)a[i].ans+=8000;
    if(a[i].qm>85&&a[i].bj>80)a[i].ans+=4000;
    if(a[i].qm>90)a[i].ans+=2000;
    if(a[i].xb=='Y'&&a[i].qm>85)a[i].ans+=1000;
    if(a[i].bj>80&&a[i].bgb=='Y')a[i].ans+=850;
    a[i].sum=i;
    tot+=a[i].ans;
    }
    sort(a+1,a+n+1,cmp);
    cout<<a[1].xm<<endl<<a[1].ans<<endl<<tot;
    return 0;
    }

  • 0
    @ 2019-03-26 16:34:36

    c的题解:

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    typedef struct stu
    {
        char name[20];
        int final_grade;
        int banji_grade;
        char ganbu;
        char west;
        int lunwen;
        struct stu *next;
    }stu;
    
    int main(int argc, const char * argv[]) {
        int n,i=0;//个数
        int maxsum=0;
        int sum=0;
        char name1[20];
        scanf("%d",&n);
        while(i<n)
        {
            int s=0;
            stu *stu1 = malloc(sizeof(stu));
            scanf("%s",stu1->name);
            scanf("%d",&stu1->final_grade);
            scanf("%d",&stu1->banji_grade);
            scanf(" %c %c",&stu1->ganbu,&stu1->west);
            scanf("%d",&stu1->lunwen);
            if(stu1->final_grade>80 && stu1->lunwen>=1)
                s+=8000;
            if(stu1->final_grade>85 && stu1->banji_grade>80)
                s+=4000;
            if(stu1->final_grade>90)
                s+=2000;
            if(stu1->final_grade>85 &&stu1->west=='Y')
                s+=1000;
            if(stu1->ganbu=='Y' && stu1->banji_grade>80)
                s+=850;
            
            sum+=s;
            if(s>maxsum)
            {
                strcpy(name1,stu1->name);
                maxsum=s;
            }
            stu1 = stu1->next;
            i++;
            }
        printf("%s\n%d\n%d",name1, maxsum, sum);
        return 0;
    }
    
    
    
  • 0
    @ 2019-01-25 21:43:44

    #include <stdio.h>
    #include<iostream>
    int n;
    const int Y = 1, N = 0, Maxn = 10001;
    using namespace std;
    struct student
    {
    char name;
    int grades1;
    int grades2;
    bool staff;
    bool west;
    int article;
    int prize = 0;
    }*p[Maxn];
    int main()
    {
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
    cin >> p[i]->name;
    cin >> p[i]->grades1;
    cin >> p[i]->grades2;
    cin >> p[i]->staff;
    cin >> p[i]->west;
    cin >> p[i]->article;
    if (p[i]->article >= 1 && p[i]->grades1>80)
    p[i]->prize += 8000;
    if (p[i]->grades1>85 && p[i]->grades2>80)
    p[i]->prize += 4000;
    if (p[i]->grades1>90)
    p[i]->prize += 2000;
    if (p[i]->grades1>85 && p[i]->west == Y)
    p[i]->prize += 1000;
    if (p[i]->grades2>80 && p[i]->staff == Y)
    p[i]->prize += 850;
    }
    for (int i = 1; i <= n; i++)
    if (p[i]->prize>p[0]->prize)
    p[0]->prize = p[i]->prize;
    cout << p[0]->prize << endl;
    return 0;

    }

  • 0
    @ 2019-01-14 19:59:05
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    int n,f,b,ls,ans;char x,y;
    struct node{
        char a[23];int sum,id;
    }a[1010];
    bool cmp(node x,node y){
        if (x.sum!=y.sum) return x.sum>y.sum;
        else return x.id<y.id;
    }
    int main(){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%s %d %d %c %c %d",&a[i].a,&f,&b,&x,&y,&ls);
            int s=0;
            if (f>80&&ls>0) s+=8000;
            if (f>85&&b>80) s+=4000;
            if (f>90) s+=2000;
            if (f>85&&y=='Y') s+=1000;
            if (b>80&&x=='Y') s+=850;
            a[i].sum=s;a[i].id=i;
        }
        sort(a+1,a+n+1,cmp);
        for(int i=1;i<=n;i++)
            ans+=a[i].sum;
        printf("%s\n%d\n%d\n",a[1].a,a[1].sum,ans);
        return 0;//ok
    }
    
  • 0
    @ 2019-01-14 19:59:05
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    int n,f,b,ls,ans;char x,y;
    struct node{
        char a[23];int sum,id;
    }a[1010];
    bool cmp(node x,node y){
        if (x.sum!=y.sum) return x.sum>y.sum;
        else return x.id<y.id;
    }
    int main(){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%s %d %d %c %c %d",&a[i].a,&f,&b,&x,&y,&ls);
            int s=0;
            if (f>80&&ls>0) s+=8000;
            if (f>85&&b>80) s+=4000;
            if (f>90) s+=2000;
            if (f>85&&y=='Y') s+=1000;
            if (b>80&&x=='Y') s+=850;
            a[i].sum=s;a[i].id=i;
        }
        sort(a+1,a+n+1,cmp);
        for(int i=1;i<=n;i++)
            ans+=a[i].sum;
        printf("%s\n%d\n%d\n",a[1].a,a[1].sum,ans);
        return 0;//ok
    }
    
  • 0
    @ 2019-01-11 11:54:13

    #include<iostream>
    using namespace std;
    int main()
    {
    string a,g;
    int b,c,f,n,money=0,result=0,sum=0;
    char d,e;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>a>>b>>c>>d>>e>>f;
    money=0;
    if(b>80&&f>=1)
    money+=8000;
    if(b>85&&c>80)
    money+=4000;
    if(b>90)
    money+=2000;
    if(b>85&&e=='Y')
    money+=1000;
    if(c>80&&d=='Y')
    money+=850;
    sum+=money;
    if(result<money)
    {
    result=money;
    g=a;
    }
    }
    cout<<g<<endl<<result<<endl<<sum<<endl;
    return 0;
    }

  • 0
    @ 2018-12-19 21:50:03

    用sort会因为名字问题过不了,
    改用stable_sort。

    • Accepted
    • # 状态 耗时 内存占用
    • #1 Accepted 1ms 336.0 KiB
    • #2 Accepted 1ms 216.0 KiB
    • #3 Accepted 1ms 216.0 KiB
    • #4 Accepted 1ms 220.0 KiB
    • #5 Accepted 1ms 344.0 KiB
    • #6 Accepted 1ms 216.0 KiB
    • #7 Accepted 1ms 344.0 KiB
    • #8 Accepted 1ms 344.0 KiB
    • #9 Accepted 1ms 216.0 KiB
    • #10 Accepted
    #include<iostream>
    #include<algorithm>
    #include<string>
    using namespace std;
    //呵呵
    //大神万岁
    //分割线--------------------------------------------------$
    //结构定义区
    struct student{
        int qm,bj,lw;
        int money;
        bool gb,xb;
        string name;
        student(string s,int q,int b,char g,char x,int l)
        {
            name=s;
            qm=q;
            bj=b;
            if(g=='Y') gb=true;
            else gb=false;
            if(x=='Y') xb=true;
            else xb=false;
            lw=l;
            money=0;
            if(qm>80 && lw>=1) money+=8000;
            if(qm>85 && bj>80) money+=4000;
            if(qm>90) money+=2000;
            if(qm>85 && xb==true) money+=1000;
            if(bj>80 && gb==true) money+=850;
        }
        student()
        {
            student("",0,0,'N','N',0);
        }
    }; 
    struct cmp{
        bool operator() (student a,student b)
        {
            return a.money>b.money;
        }
    };
    //全局变量区
    student stu[101];
    int n,all;
    //函数声明区
    
    //主函数开始!
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>n;
        for(int i=0;i<n;i++)
        {
            string str;
            int a,b,e;
            char c,d;
            cin>>str>>a>>b>>c>>d>>e;
            stu[i]=student(str,a,b,c,d,e);
            all+=stu[i].money;
        }
        stable_sort(stu,stu+n,cmp());
        cout<<stu[0].name<<endl<<stu[0].money<<endl<<all<<endl;
        return 0;
    }
    //函数实现区
    

信息

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