471 条题解

  • 31
    @ 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
    @ 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)
    
    
  • 1
    @ 2021-02-16 15:06:39

  • 1
    @ 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。有跟简单的方法吗?)

  • 1
    @ 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;
    }
    
    
    
  • 1
    @ 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 ; 
    }
    
  • 1
    @ 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;
    }
    
  • 1
    @ 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.
    
  • 1
    @ 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
    @ 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
    @ 2021-03-20 14:08:22

  • 0
    @ 2021-02-24 18:47:56

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    int n,score1,score2,sum=0,max=0,total=0,x,i;
    char a,b;
    string name,maxn;
    cin>>n;
    for(i=1;i<=n;i++)
    {
    cin>>name>>score1>>score2>>a>>b>>x;
    if(score1>80 && x>0)//判断是否获得院士奖学金
    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>max)//找出最牛学生
    maxn=name,max=sum;//sum的用处
    sum=0;
    }
    cout<<maxn<<endl<<max<<endl<<total;
    return 0;
    }

  • 0
    @ 2021-01-14 16:19:58

    简单的结构体问题
    ```c
    #include <stdio.h>
    struct student
    {
    char name[30];
    int score1;
    int score2;
    char y1;
    char y2;
    int num;
    }st[120];
    int main()
    {
    int n=0;
    scanf("%d",&n);
    int max=0,all=0;
    int who;
    for(int i=0;i<n;i++)
    {
    scanf("%s %d %d %c %c %d",&st[i].name,&st[i].score1,&st[i].score2,&st[i].y1,&st[i].y2,&st[i].num);
    int prize=0;
    if (st[i].score1>80&&st[i].num>0)
    prize+=8000;
    if (st[i].score1>85&&st[i].score2>80)
    prize+=4000;
    if (st[i].score1>90)
    prize+=2000;
    if (st[i].score1>85&&st[i].y2=='Y')
    prize+=1000;
    if (st[i].score2>80&&st[i].y1=='Y')
    prize+=850;

    if (prize>max)
    {
    max=prize;
    who=i;
    }

    all+=prize;
    }
    printf("%s\n%d\n%d",st[who].name,max,all);
    return 0;
    }
    ```

  • 0
    @ 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;
    }
    
  • 0
    @ 2020-09-16 21:30:02
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    struct Student
    {
        string name;
        int id,aver,comm,acti,total;
        bool west,stu;
    }student[105];
    int cmp(Student a,Student b)
    {
        if(a.total==b.total)
        return a.id<b.id;
        return a.total>b.total;
    }
    int main()
    {
        int n;
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            char isWest,isStu;
            cin>>student[i].name>>student[i].aver>>student[i].comm>>isStu>>isWest>>student[i].acti;
            student[i].stu=(isStu=='Y')?true:false;
            student[i].west=(isWest=='Y')?true:false;
            student[i].id=i;
        }
        int res=0;
        for(int i=1;i<=n;i++)
        {
            if(student[i].aver>80&&student[i].acti>=1)
            student[i].total+=8000,res+=8000;
            else;
            if(student[i].aver>85&&student[i].comm>80)
            student[i].total+=4000,res+=4000;
            else;
            if(student[i].aver>90)
            student[i].total+=2000,res+=2000;
            else;
            if(student[i].aver>85&&student[i].west)
            student[i].total+=1000,res+=1000;
            else;
            if(student[i].comm>80&&student[i].stu)
            student[i].total+=850,res+=850;
            else;
        }
        sort(student+1,student+1+n,cmp);
        cout<<student[1].name<<endl<<student[1].total<<endl<<res<<endl;
        return 0;
    }
    
  • 0
    @ 2020-08-21 11:10:26
    #include<bits/stdc++.h>
    using namespace std;
    struct student 
    {
        string name;
        int qm;
        int py;
        char mas;
        char wes;
        int lw;
        int mai;
    };
    student a[1001];
    int main() 
    {
        int n;
        int addmai=0;
        int k=0;
        int maxmai=-100;
        cin>>n;
        for(int i=0; i<n; i++) 
    {
            cin>>a[i].name;
            cin>>a[i].qm>>a[i].py;
            cin>>a[i].mas>>a[i].wes;
            cin>>a[i].lw;
        }
        for(int i=0; i<n; i++) 
    {
            if(a[i].qm>80&&a[i].lw>=1)a[i].mai+=8000;
            if(a[i].qm>85&&a[i].py>80)a[i].mai+=4000;
            if(a[i].qm>90)a[i].mai+=2000;
            if(a[i].qm>85&&a[i].wes=='Y')a[i].mai+=1000;
            if(a[i].py>80&&a[i].mas=='Y')a[i].mai+=850;
            addmai+=a[i].mai;
            if(maxmai!=a[i].mai) 
            {
                maxmai=max(maxmai,a[i].mai);
                if(maxmai==a[i].mai)k=i;
            }
        }
        cout<<a[k].name<<endl<<maxmai<<endl<<addmai<<endl;
        return 0;
    }
    
  • 0
    @ 2020-07-09 22:03:09
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,cj1,cj2,sum=0,max=0,s=0,x,i;
        char a,b;
        string ne,maxx;
        cin>>n;
        for(i=1;i<=n;i++)
        {
            cin>>ne>>cj1>>cj2>>a>>b>>x;
            if(cj1>80 && x>0)
                sum+=8000;
            if(cj1>85 && cj2>80)
                sum+=4000;
            if(cj1>90)
                sum+=2000;
            if(cj1>85 && b=='Y')
                sum+=1000;
            if(cj2>80 && a=='Y')
                sum+=850;
            s+=sum;
            if(sum>max)
                maxx=ne,max=sum;
            sum=0;
        }
        cout<<maxx<<endl<<max<<endl<<s;
        return 0;
    }
    
  • 0
    @ 2020-06-03 16:54:16
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    using namespace std;
    const int N = 100;
    struct Student
    {
        string name;
        int p;
        int y;
        char x;
        char g;
        int paper;
        int money;
    };
    Student cls[N+1];
    int main()
    {
        int n,am = 0;
        cin >> n;
        for(int i=0;i<n;i++)
        {
            cin >> cls[i].name;
            cin >> cls[i].p;
            cin >> cls[i].y;
            cin >> cls[i].g;
            cin >> cls[i].x;
            cin >> cls[i].paper;
        }
        for(int i=0;i<n;i++)
        {
            if(cls[i].p>80&&cls[i].paper>=1)
            {
                cls[i].money+=8000;
            }
            if(cls[i].p>85&&cls[i].y>80)
            {
                cls[i].money+=4000;
            }
            if(cls[i].p>90)
            {
                cls[i].money+=2000;
            }
            if(cls[i].p>85&&cls[i].x=='Y')
            {
                cls[i].money+=1000;
            }
            if(cls[i].y>80&&cls[i].g=='Y')
            {
                cls[i].money+=850;
            }
        }
        int Max=0;
        string Name;
        for(int i=0;i<n;i++)
        {
            if(Max<cls[i].money){
                Max=cls[i].money;
                Name=cls[i].name;
            }
            am+=cls[i].money;
        }
        cout << Name << endl;
        cout << Max << endl;
        cout << am;
        return 0;
    }
    

    结构体和if的简单练手题

  • 0
    @ 2020-05-31 10:23:09
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int n,m,em,sum=0,max=0,total=0,x,i;
        char a,b;
        string name,dalao;
        cin>>n;
        for(i=1;i<=n;i++){
            cin>>name>>m>>em>>a>>b>>x;
            if(m>80 && x>0){
                sum+=8000;
            }
            if(m>85 && em>80){
                sum+=4000;
            }
            if(m>90){
                sum+=2000;
            }
            if(m>85 && b=='Y'){
                sum+=1000;
            }
            if(em>80 && a=='Y'){
                sum+=850;
            }
            total+=sum;
            if(sum>max){
                dalao=name,max=sum;
            }
            sum=0;
        }
        cout<<dalao<<endl;
        cout<<max<<endl;
        cout<<total;
    }
    

    谔谔

    • @ 2020-06-05 12:28:49

      dalao可还行

信息

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