436 条题解

  • 24
    @ 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-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
    @ 2018-01-06 23:05:28

    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    #include <string.h>
    struct student
    {
    char name[20];
    int qscore;
    int bscore;
    char bangan;
    char xibu;
    int lunwen;
    int z;

    }stu[100];

    int main()
    {
    int n,i,j=0,k=0;
    struct student temp;
    char ch;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].qscore,&stu[i].bscore,&stu[i].bangan,&stu[i].xibu,&stu[i].lunwen);
    stu[i].z=0;
    if(stu[i].qscore>80&&stu[i].lunwen>=1)
    stu[i].z=stu[i].z+8000;
    if(stu[i].bscore>80&&stu[i].qscore>85)
    stu[i].z=stu[i].z+4000;
    if(stu[i].qscore>90)
    stu[i].z=stu[i].z+2000;
    if(stu[i].xibu=='Y'&&stu[i].qscore>85)
    stu[i].z=stu[i].z+1000;
    if(stu[i].bangan=='Y'&&stu[i].bscore>80)
    stu[i].z=stu[i].z+850;
    k=k+stu[i].z;
    }
    for(i=0;i<n-1;i++)
    {
    for(j=0;j<n-1;j++)
    {
    if(stu[j].z<stu[j+1].z)
    {
    temp=stu[j];
    stu[j]=stu[j+1];
    stu[j+1]=temp;
    }
    }
    }
    temp=stu[0];
    for(i=1;stu[i].z==temp.z&&i<n;i++)
    {
    if(strcmp(stu[i].name,temp.name)<0)
    temp=stu[i];
    }
    printf("%s\n%d\n%d",temp.name,temp.z,k);
    return 0;
    }

  • 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-02-24 16:11:18

    这题只要用一个结构体就能完成,特别简单
    cpp
    #include <iostream>
    #include <cstdio>
    using namespace std;
    struct Student {
    char name[21];//姓名
    int end_score;//期末分数
    int class_score;//班级分数
    char head;//是否学生干部
    char west;//是否西部学生
    int passages;//发布论文数
    int money;//奖学金
    };
    int main() {
    struct Student students[102];
    int n,max=0,sum=0;//max用于存储最高的下标
    cin >> n;
    for (int i=0;i<n;i++)
    scanf("%s %d %d %c %c %d",students[i].name,&students[i].end_score,&students[i].class_score,&students[i].head,&students[i].west,&students[i].passages);//依次输入
    for (int i=0;i<n;i++) {//依次计算
    students[i].money=0;//初始化
    if (students[i].end_score>80 && students[i].passages>=1)//第一种情况
    students[i].money+=8000;
    if (students[i].end_score>85 && students[i].class_score>80)//以此类推
    students[i].money+=4000;
    if (students[i].end_score>90)
    students[i].money+=2000;
    if (students[i].end_score>85 && students[i].west=='Y')
    students[i].money+=1000;
    if (students[i].class_score>80 && students[i].head=='Y')
    students[i].money+=850;
    if (students[i].money>students[max].money)
    max=i;
    sum+=students[i].money;
    }
    printf("%s\n%d\n%d",students[max].name,students[max].money,sum);
    return 0;
    }

  • 0
    @ 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;
    }
    
  • 0
    @ 2019-01-31 05:08:19
    #python
    #学生总数
    N = int(input())
    
    #姓名,期末平均成绩,班级评议成绩,是否是学生干部,是否是西部省份学生,发表的论文数
    #院士奖学金,每人8000元,期末平均成绩高于80分(>80),并且在本学期内发表1篇或1篇以上论文的学生均可获得;
    #五四奖学金,每人4000元,期末平均成绩高于85分(>85),并且班级评议成绩高于80分(>80)的学生均可获得;
    #成绩优秀奖,每人2000元,期末平均成绩高于90分(>90)的学生均可获得;
    #西部奖学金,每人1000元,期末平均成绩高于85分(>85)的西部省份学生均可获得;
    #班级贡献奖,每人850元,班级评议成绩高于80分(>80)的学生干部均可获得;
    
    
    def money(name, score, cscore, manager, west, papers):
    
        s = 0
        if score > 80 and papers >= 1:
            s += 8000
        if score > 85 and cscore > 80:
            s += 4000
        if score > 90:
            s += 2000
        if score > 85 and west == 'Y':
            s += 1000
        if cscore > 80 and manager == 'Y':
            s += 850
        return name, s
    
    
    x = []
    y = []
    
    for i in range(N):
        name, score, cscore, manager, west, papers = input().split()
        score = int(score)
        cscore = int(cscore)
        papers = int(papers)
        t = money(name, score, cscore, manager, west, papers)
        y += [t[0]]
        x += [t[1]]
    
    for i in range(N):
        if x[i] == max(x):
            print(y[i])
            print(x[i])
            print(sum(x))
            break
    
    
  • 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;
    }
    //函数实现区
    
  • 0
    @ 2018-12-18 01:00:28

    #include <stdio.h>
    #include <stdlib.h>
    struct student
    {
    char name[21];
    int aver;
    int ban;
    char gb;
    char west;
    int num;
    int money;
    } stu[101];
    int cmp(const void *a,const void b)
    {
    return (
    (struct student )b).money-((struct student *)a).money;
    }
    int main()
    {
    int N,i,j;
    scanf("%d",&N);
    for(i=0; i<N; i++){
    scanf("%s %d %d %c %c %d",stu[i].name,&stu[i].aver,&stu[i].ban,&stu[i].gb,&stu[i].west,&stu[i].num);
    stu[i].money=0;
    if(stu[i].aver>80&&stu[i].num>=1) stu[i].money+=8000;
    if(stu[i].aver>85&&stu[i].ban>80) stu[i].money+=4000;
    if(stu[i].aver>90) stu[i].money+=2000;
    if(stu[i].west=='Y'&&stu[i].aver>85) stu[i].money+=1000;
    if(stu[i].ban>80&&stu[i].gb=='Y') stu[i].money+=850;
    }
    int sum=0;
    for(j=0; j<N; j++)
    sum+=stu[j].money;
    qsort(stu,N,sizeof(struct student),cmp);
    printf("%s\n",stu[0].name);
    printf("%d\n",stu[0].money);
    printf("%d\n",sum);
    }

  • 0
    @ 2018-11-26 19:37:51

    #include <iostream>
    using namespace std;
    int main()
    {
    int n,i,j1=0,j2=0,j3=0;//学生数 当前学生奖学金 最高奖学金 总奖学金
    string m1,m2;//名字
    int q1,q2,p1,p2,l1,l2;//期末 评议 论文
    char g1,g2,x1,x2;//干部 西部
    cin>>n;
    for(i=0;i<n;i++)
    {
    j1=0;
    cin>>m1>>q1>>p1>>g1>>x1>>l1;
    if(q1>80&&l1>=1)
    j1=j1+8000;
    if(q1>85&&p1>80)
    j1=j1+4000;
    if(q1>90)
    j1=j1+2000;
    if(q1>85&&x1=='Y')
    j1=j1+1000;
    if(p1>80&&g1=='Y')
    j1=j1+850;
    if(j1>j2)
    {
    j2=j1;m2=m1;
    }
    j3+=j1;
    }
    cout<<m2<<endl<<j2<<endl<<j3<<endl;
    return 0;
    }

  • 0
    @ 2018-11-25 17:26:07

    c++代码
    #include<bits/stdc++.h>
    using namespace std;
    int n,sum,ans=1;
    struct Int{
    char mz[20],gb,xb;
    int qm,py,lv,tsum;
    void input(){
    cin>>mz;
    cin>>qm;
    cin>>py;
    cin>>gb;
    cin>>xb;
    cin>>lv;
    }
    void output(){
    printf("%s\n",mz);
    printf("%d\n",tsum);
    }
    void ys(){
    if(qm>80 && lv>=1){
    sum+=8000;
    tsum+=8000;
    }
    }
    void ws(){
    if(qm>85 && py>80){
    sum+=4000;
    tsum+=4000;
    }
    }
    void cj(){
    if(qm>90){
    sum+=2000;
    tsum+=2000;
    }
    }
    void xbj(){
    if(qm>85 && xb=='Y'){
    sum+=1000;
    tsum+=1000;
    }
    }
    void bj(){
    if(py>80 && gb=='Y'){
    sum+=850;
    tsum+=850;
    }
    }
    }a[101];
    int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
    a[i].input();
    a[i].ys();
    a[i].ws();
    a[i].cj();
    a[i].xbj();
    a[i].bj();
    }
    for(int i=2;i<=n;i++)
    if(a[ans].tsum<a[i].tsum) ans=i;
    a[ans].output();
    printf("%d",sum);
    return 0;
    }

  • 0
    @ 2018-11-07 14:42:46

    #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; //n个学生,总的奖学金
    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; //没有renturn 0也能AC,不过最好加上
    }

  • 0
    @ 2018-11-05 13:48:26

    简单题,结构体+排序一边走起

    #include<bits/stdc++.h>
    using namespace std;
    struct student{
        string name;
        int cj1,cj2;
        char gb,xb;
        int lw;
        int num,ans=0;
    }d[100000];
    int n,total=0;
    bool cmp(student a,student b)
    {
        if(a.ans==b.ans) return a.num<b.num;
        else return a.ans>b.ans;
    }
    int main()
    {
        cin>>n;
        for(int i=1; i<=n; i++)
        {
            cin>>d[i].name>>d[i].cj1>>d[i].cj2>>d[i].gb>>d[i].xb>>d[i].lw;
            d[i].num=i;
            if(d[i].cj1>80 && d[i].lw>=1) d[i].ans+=8000;
            if(d[i].cj1>85 && d[i].cj2>80) d[i].ans+=4000;
            if(d[i].cj1>90) d[i].ans+=2000;
            if(d[i].xb=='Y' && d[i].cj1>85) d[i].ans+=1000;
            if(d[i].gb=='Y' && d[i].cj2>80) d[i].ans+=850;
            total+=d[i].ans;
        }
        sort(d+1,d+n+1,cmp);
        cout<<d[1].name<<endl<<d[1].ans<<endl<<total<<endl;
        return 0;
    }
    
  • 0
    @ 2018-10-10 16:07:48

    #include "stdafx.h"
    #include <iostream>
    #include <string>

    using namespace std;

    struct stu {
    string name;
    int qm, bj, lw;
    char gb, xb;
    int jx=0;

    };
    int main()
    {
    using namespace std;

    int rs;
    cin >> rs;

    stu* xs = new stu[rs];

    for (int i = 0; i < rs; i++) {
    cin >> xs[i].name >> xs[i].qm >> xs[i].bj >> xs[i].gb >> xs[i].xb >> xs[i].lw;
    }

    for (int i = 0; i < rs; i++) {
    if (xs[i].qm>80 && xs[i].lw >= 1) xs[i].jx += 8000;
    if (xs[i].qm>85 && xs[i].bj>80) xs[i].jx += 4000;
    if (xs[i].qm>90) xs[i].jx += 2000;
    if (xs[i].qm>85 && xs[i].xb == 'Y') xs[i].jx += 1000;
    if (xs[i].bj>80) xs[i].jx += 850;
    }

    int max = 0;
    int a = 0;
    for (int i = 0; i<rs; i++) {
    a += xs[i].jx;
    if (xs[i].jx>xs[max].jx) {
    max = i;
    }
    }
    cout << xs[max].name << endl;
    cout << xs[max].jx << endl;
    cout << a << endl;

    }

  • 0
    @ 2018-10-09 10:43:55
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    struct student{
        string name;
        int qimo;
        int banping;
        char monitor;
        char west;
        int lun;
        int money=0;
        int num;
    };
    bool cmp(student x,student y){
        if(x.money !=y.money ) return x.money >y.money ;
        return x.num <y.num ;
    }
    int main(){
        int n;
        scanf("%d",&n);
        student ss[n];
        long long sum=0;
        for(int i=0;i<n;i++){
            ss[i].num =i;
            cin>>ss[i].name >>ss[i].qimo >>ss[i].banping >>ss[i].monitor >>ss[i].west >>ss[i].lun ;
            if(ss[i].qimo >80&&ss[i].lun >=1) ss[i].money +=8000;
            if(ss[i].qimo >85&&ss[i].banping >80) ss[i].money +=4000;
            if(ss[i].qimo >90) ss[i].money +=2000;
            if(ss[i].qimo >85&&ss[i].west=='Y') ss[i].money +=1000;
            if(ss[i].banping >80&&ss[i].monitor =='Y') ss[i].money +=850;
            sum+=ss[i].money ;
        }
        sort(ss,ss+n,cmp);
        cout<<ss[0].name <<endl<<ss[0].money <<endl<<sum<<endl;
        return 0;
    }
    

信息

ID
1001
难度
5
分类
模拟 点击显示
标签
递交数
32605
已通过
10925
通过率
34%
上传者