508 条题解

  • 32
    @ 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;
    }
    
    • @ 2024-08-27 20:33:06

      修改一下格式哦,像下面这样写,会更好:

      #include <iostream>
      using namespace std;
      int main(void) {
          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;
          cout << result << endl;
          cout << sum << endl;
          return 0;
      }
      
  • 4
    @ 2020-12-22 19:04:20
    info = list()
    money = 0
    ans = 0
    total = 0
    
    for i in range(int(input())):
        info = list(input().split(" "))
        if int(info[1])>80 and int(info[5])>=1:
            money+=8000
        if int(info[1])>85 and int(info[2])>80:
            money+=4000
        if int(info[1])>90:
            money+=2000
        if int(info[1])>85 and info[4]=='Y':
            money+=1000
        if int(info[2])>80 and info[3]=='Y':
            money+=850
        if money > ans:
            ans = money
            name = info[0]
        total+=money
        money = 0
    
    print(name)
    print(ans)
    print(total)
    

    快乐Python。有跟简单的方法吗?)

    • @ 2021-12-20 18:27:29
      #include<bits/stdc++.h>
      using namespace std;
      int n,mx,sum; 
      string ans;
      int main(){
          cin>>n;
          for(int i=1;i<=n;i++)
          {
              string a;
              int b,c,f;
              char d,e;
              cin>>a>>b>>c>>d>>e>>f;
              int price=(b>80)*(f>=1)*8000+(b>85)*(c>80)*4000+(b>90)*2000+(b>85)*(e=='Y')*1000+(c>80)*(d=='Y')*850;
              if(price>mx)
              {
                  mx=price;
                  ans=a;
              }
              sum+=price;
          }
          cout<<ans<<endl<<mx<<endl<<sum;
          return 0;
      }
      
  • 3
    @ 2020-10-18 10:43:54

    吐血了,这题目是有点问题的吧!
    总感觉西部和班干部这里的金额反了。做了N次,出错。可能是我理解能力的问题吧!勿喷,谢谢。做得很一般,没有写得很精简,但是也不难理解。喜欢的老铁,帮忙点赞。谢谢

    #include <iostream>
    #include <cstdio>
    #include <string.h>
    using namespace std;
    
    //学生信息结构体 按顺序:名字 平均分 评分 西部 班干 论文数 奖学金
    struct student
    {
        string name;
        int aScore;
        int pScore;
        char wStu;
        char classL;
        int paper;
        int money = 0;
    } stu[100];
    
    //统计一个学生奖学金的方法
    int moneyFor(student stuN)
    {
        if (stuN.aScore > 80 && stuN.paper >= 1)
        {
            stuN.money += 8000;
        }
        if (stuN.aScore > 85 && stuN.pScore > 80)
        {
            stuN.money += 4000;
        }
        if (stuN.aScore > 90)
        {
            stuN.money += 2000;
        }
        if (stuN.pScore > 80 && stuN.wStu == 'Y')
        {
            stuN.money += 850;
        }
        if (stuN.aScore > 85 && stuN.classL == 'Y')
        {
            stuN.money += 1000;
        }
    
        return stuN.money;
    }
    
    int main()
    {
        int n = 0;
        int firstMoney = 0, sum = 0;
        int j = 0;
        cin >> n;
        for (int i = 0; i < n; i++)
        {
            cin >> stu[i].name >> stu[i].aScore >> stu[i].pScore >> stu[i].wStu >> stu[i].classL >> stu[i].paper;
            stu[i].money = 0;
            stu[i].money=moneyFor(stu[i]);
            sum += stu[i].money;
            if (firstMoney < stu[i].money)
            {
                firstMoney = stu[i].money;
                j = i;
            }
        }
        cout << stu[j].name << "\n"
             << firstMoney << "\n"
             << sum << endl;
        //system("pause");
        return 0;
    }
    
    
    
  • 3
    @ 2009-04-04 09:45:58

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

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

  • 2
    @ 2021-01-19 22:52:51

    python用**二维列表存数据**
    注意题目**一个学生可能获得多个奖项**所以只用if语句

    def get_price(name,grade,j_grade,work,student,paper):
        price = 0
        if grade > 80 and paper >= 1:
            price+=8000
        if grade > 85 and j_grade > 80:
            price+=4000
        if grade > 90:
            price+=2000
        if grade > 85 and student == 'Y':
            price+=1000
        if j_grade > 80 and work == 'Y':
            price+=850
        return list((price,name))
    num = eval(input())
    lst = []
    lst_mess = [list(map(str,input().split())) for x in range(num)]
    for i in range(num):
        lst.append(get_price(lst_mess[i][0],eval(lst_mess[i][1]),eval(lst_mess[i][2]),lst_mess[i][3],lst_mess[i][4],eval(lst_mess[i][5])))
    max_num = 0
    name_max = ''
    for i in range(len(lst)):
        if lst[i][0] > max_num:
            max_num = lst[i][0]
            name_max = lst[i][1]
    sum = 0
    for i in range(num):
        sum+=lst[i][0]
    print(name_max)
    print(max_num)
    print(sum)
    
    
  • 2
    @ 2020-09-12 17:12:36
    #include <iostream>
    #include <cstdio>
    #include <algorithm>
    
    struct people{
        std::string name;
        int qi, ban, lun, num, id;
        char student, xibu;
    }a[50000];
    
    bool comp(people x, people y){
        if(x.num == y.num) return x.id < y.id;
        return x.num > y.num; 
    }
    
    int judge(int &num, int qi, int ban, char student, char xibu, int lun){
        num = 0;
        if(qi > 80 and lun >= 1) num += 8000;
        if(qi > 85 and ban > 80) num += 4000; 
        if(qi > 90 ) num += 2000;
        if(qi > 85 and xibu == 'Y') num += 1000;
        if(ban > 80 and student == 'Y') num += 850;
        return 0 ;
    }
    
    int n, ans;
    
    int main(){
        scanf("%d" , &n);
        for(int i = 0; i < n; i ++){
            std :: cin >> a[i].name;
            scanf("%d%d%s%s%d", &a[i].qi, &a[i].ban, &a[i].student, &a[i].xibu, &a[i].lun);
            judge(a[i].num, a[i].qi, a[i].ban, a[i].student, a[i].xibu, a[i].lun);
            ans += a[i].num;
            a[i].id = i;
        }
        std :: sort(a, a+n, comp ) ;
        std :: cout << a[0].name << "\n";
        printf("%d\n%d", a[0].num, ans);
            return 0 ; 
    }
    
  • 2
    @ 2020-08-02 12:26:36

    一道模拟题,用结构体struct存入每位学生的信息,之后一次判断即可。

    注意:题目中说每位学生可以获得多项奖,所以使用if语句并列写,如题目中写每位学生只能获得最先拿到的一项奖,则应使用if……else语句!

    \(Code\)

    #include<bits/stdc++.h>
    using namespace std;
    int n;
    struct node{
        string name;
        int sc;
        int score;
        char f;
        char f1;
        int num;
        int sum;
        int m; 
    }a[110];
    /*
    name:姓名
    sc:期末成绩
    score:评测成绩
    f:是否为干部
    f1:是否为西部学生
    num:论文数
    sum:奖学金数
    m;编号 
    */
    bool cmp(node c,node d){
        if(c.sum>d.sum||c.sum==d.sum&&c.m<d.m){
            return true;
        }else{
            return false;
        }
    }
    int s3;
    int main(){
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i].name>>a[i].sc>>a[i].score>>a[i].f>>a[i].f1>>a[i].num;
            a[i].m=i;
        }
        for(int i=1;i<=n;i++){
            if(a[i].sc>80&&a[i].num>=1){
                a[i].sum+=8000;
            }
            if(a[i].sc>85&&a[i].score>80){
                a[i].sum+=4000;
            }
            if(a[i].sc>90){
                a[i].sum+=2000;
            }
            if(a[i].sc>85&&a[i].f1=='Y'){
                a[i].sum+=1000;
            }
            if(a[i].score>80&&a[i].f=='Y'){
                a[i].sum+=850;
            }
            s3+=a[i].sum;
        }
        sort(a+1,a+n+1,cmp);
        cout<<a[1].name<<endl;
        cout<<a[1].sum<<endl;
        cout<<s3;
        return 0;
    }
    
  • 2
    @ 2020-03-01 11:50:41

    竟然没有Pascal的题解,那我就来水一发

    代码

    var
      n,i,k,j,o,lw,sum,s:longint;
      x,gb,xb:string;
      a:array[1..100] of string;
      b:array[1..100] of longint;
    begin
      readln(n);
      for i:=1 to n do
        begin
          readln(x); x:=x+' ';
          k:=pos(' ',x); a[i]:=copy(x,1,k-1); delete(x,1,k);
          k:=pos(' ',x); val(copy(x,1,k-1),j); delete(x,1,k);
          k:=pos(' ',x); val(copy(x,1,k-1),o); delete(x,1,k);
          k:=pos(' ',x); gb:=copy(x,1,k-1); delete(x,1,k);
          k:=pos(' ',x); xb:=copy(x,1,k-1); delete(x,1,k);
          k:=pos(' ',x); val(copy(x,1,k-1),lw); delete(x,1,k);
          if (j>80) and (lw>=1) then inc(b[i],8000);
          if (j>85) and (o>80) then inc(b[i],4000);
          if j>90 then inc(b[i],2000);
          if (j>85) and (xb='Y') then inc(b[i],1000);
          if (o>80) and (gb='Y') then inc(b[i],850);
          if b[i]>sum then sum:=b[i];
          inc(s,b[i]);
        end;
      for i:=1 to n do
        if sum=b[i] then
          begin
            writeln(a[i]);
            writeln(b[i]);
            writeln(s);
            break;
          end;
    end.
    
  • 2
    @ 2020-02-01 16:44:13
    /*
    用类的思想对学生信息进行封装,添加学生基本信息
    定义计算学生奖学金的函数,用多个判断语句计算学生奖学金
    最后进行比较
    */
    #include <iostream>
    
    using namespace std;
    
    class students {
    public:
        char name[20], cadre, west;
        int finalgrade, classgrade, thesis, scholarship = 0;
        void scholarshipcount(void) {
            if (this->finalgrade > 80 && this->thesis > 0)scholarship += 8000;
            if (this->finalgrade > 85 && this->classgrade > 80)scholarship += 4000;
            if (this->finalgrade > 90)scholarship += 2000;
            if (this->finalgrade > 85 && this->west == 'Y')scholarship += 1000;
            if (this->classgrade > 80 && this->cadre == 'Y')scholarship += 850;
        }
        students(){}
        ~students(){}
    };
    int main()
    {
        int N, totalscholarship = 0;
        students student[100];
        cin >> N;
        for (int i = 0; i < N; i++) {
            cin >> student[i].name >> student[i].finalgrade >> student[i].classgrade >> student[i].cadre
                >> student[i].west >> student[i].thesis;
            student[i].scholarshipcount();
            totalscholarship += student[i].scholarship;
        }
        students studentbest=student[0];
        for (int i = 1; i < N; i++) {
            if (studentbest.scholarship < student[i].scholarship)studentbest = student[i];
        }
        cout << studentbest.name << endl << studentbest.scholarship << endl << totalscholarship;
        return 0;
    }
    
  • 1
    @ 2024-07-17 13:13:54

    暴力解

    #include<bits/stdc++.h>
    using namespace std;
    int n,score1,score2,sum=0,maxnn=0,total=0,x,i;
    char a,b;
    string name,maxn;
    int main()
    {
        cin>>n;
        for(i=1;i<=n;i++)
        {
            cin>>name>>score1>>score2>>a>>b>>x;
            if((score1>80)&&(x>=1))//判断是否获得院士奖学金
            {
                sum+=8000;
            }
            if((score1>85)&&(score2>80))//判断是否获得五四奖学金
            {
                sum+=4000;
            }
            if(score1>90)//判断是否获得成绩优秀奖
            {
                sum+=2000;
            }
            if((score1>85)&&(b=='Y'))//判断是否获得西部奖学金
            {
                sum+=1000;
            }
            if((score2>80)&&(a=='Y'))//判断是否获得班级贡献奖
            {
                sum+=850;
            }
            total+=sum;//累加奖学金
            if(sum>maxnn)//找出最牛学生
            {
                maxn=name,maxnn=sum;//sum的用处
            }
            sum=0;
        }
        cout<<maxn<<endl<<maxnn<<endl<<total;
        return 0;
    }
    
  • 1
    @ 2024-03-28 22:00:52

    温柔的结构体:)(C++)

    #include<bits/stdc++.h>
    using namespace std;
    void yo(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }
    int n;
    long long sum;
    struct stu{
        string name;
        int qp,pp,wens,id;
        char gb,x;
        long long stumoney_ans;
        bool friend operator <(stu a1,stu a2){
            return a1.stumoney_ans>a2.stumoney_ans || a1.stumoney_ans==a2.stumoney_ans&&a1.id<a2.id;
        }
    };
    stu a[160];
    int main(){
        yo();
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i].name>>a[i].qp>>a[i].pp>>a[i].gb>>a[i].x>>a[i].wens;
            a[i].id=i;
        }
        for(int i=1;i<=n;i++){
            if(a[i].qp>80&&a[i].wens>0) a[i].stumoney_ans+=8000;
            if(a[i].qp>85&&a[i].pp>80) a[i].stumoney_ans+=4000;
            if(a[i].qp>90) a[i].stumoney_ans+=2000;
            if(a[i].qp>85&&a[i].x=='Y') a[i].stumoney_ans+=1000;
            if(a[i].pp>80&&a[i].gb=='Y') a[i].stumoney_ans+=850;
            sum+=a[i].stumoney_ans;
        }
        sort(a+1,a+n+1);
        cout<<a[1].name<<"\n"<<a[1].stumoney_ans<<"\n"<<sum;
        return 0;
    }
    
    
  • 1
    @ 2022-10-06 10:43:47

    纯暴力模拟

    #include<bits/stdc++.h>
    using namespace std;
    string a[105];//姓名
    short b[105],c[105];//期末成绩和班级评议成绩
    char d[105];//是否学生干部
    char e[105];//是否西部省份学生
    short f[105];//论文数量
    short g[105];//奖学金
    int main()
    {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    short h;
    cin>>h;
    for(int i=0;i<h;i++)
    {
    cin>>a[i];
    cin>>b[i];
    cin>>c[i];
    cin>>d[i];
    cin>>e[i];
    cin>>f[i];
    g[i]=0;
    if(b[i]>80&&f[i]>0) g[i]+=8000;
    if(b[i]>85&&c[i]>80) g[i]+=4000;
    if(b[i]>90) g[i]+=2000;
    if(b[i]>85&&e[i]=='Y')g[i]+=1000;
    if(c[i]>80&&d[i]=='Y')g[i]+=850;
    }
    int j=0,k,l=0;
    for(int m=0;m<h;m++)
    {
    l+=g[m];
    if(g[m]>j)
    {
    j=g[m];
    k=m;
    }
    }
    cout<<a[k]<<"\n"<<j<<"\n"<<l;
    return 0;
    }

    压行后
    #include<bits/stdc++.h>
    using namespace std;string a[105];short b[105],c[105];char d[105];char e[105];short f[105];short g[105];int main(){ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);short h;cin>>h;for(int i=0;i<h;i++){cin>>a[i];cin>>b[i];cin>>c[i];cin>>d[i];cin>>e[i];cin>>f[i];g[i]=0;if(b[i]>80&&f[i]>0)g[i]+=8000;if(b[i]>85&&c[i]>80)g[i]+=4000;if(b[i]>90)g[i]+=2000;if(b[i]>85&&e[i]=='Y')g[i]+=1000;if(c[i]>80&&d[i]=='Y')g[i]+=850;}int j=0,k,l=0;for(int m=0;m<h;m++){l+=g[m];if(g[m]>j){j=g[m];k=m;}}cout<<a[k]<<"\n"<<j<<"\n"<<l;return 0;

  • 1
    @ 2022-06-26 17:41:10

    普通模拟题

    #include <iostream>
    #include <cstring>
    #include <algorithm>
    #include <cstdio>
    #include <cmath>
    using namespace std;
    
    int main()
    {
        int n, mx = 0, ans = 0;
        string mx_name;
        scanf("%d", &n);
        for (int i = 1; i <= n; i ++ )
        {
            string name;
            int a, b, e, sum = 0;
            char c, d;
            cin >> name;
            scanf("%d%d", &a, &b);
            cin >> c >> d;
            scanf("%d", &e);
            if (a > 80 && e >= 1) //院士奖学金
            {
                sum += 8000;
            }
            if (a > 85 && b > 80) //五四奖学金
            {
                sum += 4000;
            }
            if (a > 90) //成绩优秀奖
            {
                sum += 2000;
            }
            if (a > 85 && d == 'Y') //西部奖学金
            {
                sum += 1000;
            }
            if (b > 80 && c == 'Y') //班级贡献奖
            {
                sum += 850;
            }
            ans += sum; //奖学金总数
            if (mx < sum) //更新mx, 注意mx_name也要更新
            {
                mx_name = name;
                mx = sum;
            }
        }
        cout << mx_name;
        printf("\n%d\n%d", mx, ans);
        return 0;
    }
    
  • 1
    @ 2022-05-17 21:05:37

    最短代码

    using namespace std;
    int main(int argc, char** argv) {
        int a=0,Qimo,Pingyi,Lunwen,s,t,zs;string xibu,ganbu,name,zn;
        cin>>a;
        for(int i=0;i<a;i++){
            t=0; 
    cin>>name;cin>>Qimo;cin>>Pingyi;cin>>ganbu;cin>>xibu;cin>>Lunwen;
            if(Qimo>80 and Lunwen>0) t+=8000;
            if(Qimo>85 and Pingyi >80) t+=4000;
            if(Qimo >90) t+=2000;
            if(xibu == "Y" and Qimo > 85) t+= 1000;
            if(Pingyi > 80 and ganbu=="Y") t+= 850;
            if(zs<t){zs=t;zn=name;} 
            s+=t;
        }
        cout<<zn<<endl;cout<<zs<<endl;cout<<s<<endl;
        return 0;
    }
    

    有帮助的话请点个赞.

  • 1
    @ 2022-03-03 19:54:02

    此题规范方法应是结构体排序:

    #include<bits/stdc++.h>
    using namespace std;
    struct wp
    {
        int b,c,f,g,w;
        char d,e;
        string h;
    }a[110];
    bool cmp(wp x,wp y)
    {
        if(x.g!=y.g) return x.g>y.g;
        else if(x.g==y.g&&x.w!=y.w) return x.w<y.w;
    }
    int main()
    {
        int n,i,sum=0;
        cin>>n;
        for(i=1;i<=n;i++)
        {
            cin>>a[i].h>>a[i].b>>a[i].c>>a[i].d>>a[i].e>>a[i].f;
            a[i].w=i;
            if(a[i].b>80&&a[i].f>=1) a[i].g+=8000;
            if(a[i].b>85&&a[i].c>80) a[i].g+=4000;
            if(a[i].b>90) a[i].g+=2000;
            if(a[i].e=='Y'&&a[i].b>85) a[i].g+=1000;
            if(a[i].d=='Y'&&a[i].c>80) a[i].g+=850;
            sum+=a[i].g;
        }
        sort(a+1,a+n+1,cmp);
        cout<<a[1].h<<endl<<a[1].g<<endl<<sum;
        return 0;
    }
    
  • 1
    @ 2022-01-21 23:35:34

    #include<iostream>
    #include<string.h>
    using namespace std;
    class Student
    {
    public:
    string name, claS, westS;//姓名,是否为学生干部,是否为西部学生。
    int Lscore , Cscore , paper ;
    int money =0;
    void Money();//判断条件
    };
    void Student::Money()
    {
    if (paper >= 1 && Lscore > 80)money += 8000;
    if (Lscore > 85 && Cscore > 80)money += 4000;
    if (Lscore > 90)money += 2000;
    if (Lscore > 85 && westS == "Y")money += 1000;
    if (Cscore > 80 &&claS == "Y")money += 850;
    }
    int main()
    {

    string name;//获得奖金最多的人的名字
    int N,money=0,allmoney=0;//获得奖金最多的人的钱,所有人的奖金和
    cin >> N;
    for (int i = 0; i < N; i++)
    {
    Student stu;
    cin >> stu.name >> stu.Lscore >> stu.Cscore >> stu.claS >> stu.westS >> stu.paper;
    stu.Money();
    allmoney += stu.money;
    if (stu.money > money)
    {
    money = stu.money; name = stu.name;
    }
    }
    cout << name << endl;
    cout << money << endl;
    cout << allmoney << endl;
    return 0;
    }

  • 1
    @ 2021-09-18 10:56:18

    #include <iostream>\我这样写应该会更加通俗易懂/
    #include <cstring>
    using namespace std;
    int main()
    {
    string a,c;
    char g,d;
    long n,l,z,y,w=0,h=0,temp=0,num=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>a;
    cin>>l;
    cin>>z;
    cin>>g;
    cin>>d;
    cin>>y;
    if(l>80&&l<=100&&y>=1)
    w=w+8000;
    if(l>85&&l<=100&&z>80)
    w=w+4000;
    if(l>90&&l<=100)
    w=w+2000;
    if(d=='Y'&&l<=100&&l>85)
    w=w+1000;
    if(g=='Y'&&z<=100&&z>80)
    w=w+850;
    if(w>temp)
    {
    temp=w;
    c=a;
    }
    if(w==temp)
    {
    h++;
    }
    num=num+w;
    w=0;
    }
    cout<<c<<endl;
    cout<<temp<<endl;
    cout<<num<<endl;
    }

  • 1
    @ 2021-09-18 10:56:07

    #include <iostream>\我这样写应该会更加通俗易懂/
    #include <cstring>
    using namespace std;
    int main()
    {
    string a,c;
    char g,d;
    long n,l,z,y,w=0,h=0,temp=0,num=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>a;
    cin>>l;
    cin>>z;
    cin>>g;
    cin>>d;
    cin>>y;
    if(l>80&&l<=100&&y>=1)
    w=w+8000;
    if(l>85&&l<=100&&z>80)
    w=w+4000;
    if(l>90&&l<=100)
    w=w+2000;
    if(d=='Y'&&l<=100&&l>85)
    w=w+1000;
    if(g=='Y'&&z<=100&&z>80)
    w=w+850;
    if(w>temp)
    {
    temp=w;
    c=a;
    }
    if(w==temp)
    {
    h++;
    }
    num=num+w;
    w=0;
    }
    cout<<c<<endl;
    cout<<temp<<endl;
    cout<<num<<endl;
    }

  • 1
    @ 2020-12-18 16:12:29
    #include<bits/stdc++.h>
    using namespace std; 
    int main()
    {
        int mon[105];
        for(int j=0;j<106;j++) mon[j]=0;
        int n;
        cin>>n;
        string name[105];
        int test[105],fri[105],art[105];
        char help[105],east[105];
        for(int i=0;i<n;i++) cin>>name[i]>>test[i]>>fri[i]>>help[i]>>east[i]>>art[i];
        for(int i=0;i<n;i++)
        {
            if(test[i]>80&&art[i]>0) mon[i]=mon[i]+8000;
            if(test[i]>85&&fri[i]>80) mon[i]=mon[i]+4000;
            if(test[i]>90) mon[i]=mon[i]+2000;
            if(test[i]>85&&east[i]=='Y') mon[i]=mon[i]+1000;
            if(fri[i]>80&&help[i]=='Y') mon[i]=mon[i]+850;
        }
        int max=0;
        int stunum=0;
        for(int i=0;i<n;i++)
        {
            if(mon[i]>max) 
            {
               stunum=i;
               max=mon[i];
            }
        }
        cout<<name[stunum]<<endl;
        cout<<mon[stunum]<<endl;
        unsigned long long ans=0;
        for(int i=0;i<n;i++) ans=ans+mon[i];
        cout<<ans;
        return 0;
    }
    
  • 1
    @ 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;
    }

信息

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