511 条题解

  • 0

    用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

    #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
    @ 6 年前

    #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
    @ 6 年前

    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

    #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
    @ 6 年前

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

    #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
    @ 6 年前

    #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
    @ 6 年前
    #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;
    }
    
  • 0
    @ 6 年前

    WA大家能帮我看看怎么错了吗。
    ```cpp
    #include<iostream>
    #include<string>
    using namespace std;
    class stu
    {
    public:
    stu()
    {
    name ="kk" ;
    qm = 0;
    py = 0;
    gb = 'l';
    xb = 'l';
    lw = 0;
    }

    stu (string n,int q,int p,char g,char x,int l)
    {
    name =n ;
    qm = q;
    py = p;
    gb = g;
    xb = x;
    lw = l;

    }
    void xg(string n,int q,int p,char g,char x,int l)
    {

    name =n ;
    qm = q;
    py = p;
    gb = g;
    xb = x;
    lw = l;
    }

    void shuchu()
    {
    cout<<name<<endl;
    }
    int jxj()
    { int s=0;
    if(qm>80&&lw>0) s+=8000;
    if(qm>85&&py>80) s+=4000;
    if(qm>90) s+=2000;
    if(qm>85&&xb=='Y') s+=1000;
    if(py>80&&gb=='Y') s+=850;
    return s;
    }

    private:
    string name;
    int qm;
    int py;
    char gb;
    char xb;
    int lw;
    };
    int main()
    { stu s[101];
    int N;
    cin>>N;
    int q,p,l,nam=0;
    string n;
    char g,x;
    for(int i = 0;i<N;i++)
    {
    cin>>n>>q>>p>>g>>x>>l;
    s[i].xg(n,q,p,g,x,l);
    }
    for(int m = 0;m<N;m++)
    {
    nam+=s[m].jxj();
    if(s[m].jxj()>s[100].jxj())
    s[100]=s[m];

    }

    s[100].shuchu();
    cout<<s[99].jxj()<<endl<<nam;
    return 0;
    }

  • 0
    @ 6 年前
    #[derive(Debug)]
    struct Student {
        name: String,
        ave_score: i32,
        appraisal_score: i32,
        is_cadre: bool,
        is_west: bool,
        paper_count: i32,
    }
    impl Student {
        fn get_award(&self) -> usize {
            let mut award: usize = 0;
            if self.ave_score > 80 && self.paper_count >= 1 {
                award += 8000;
            };
            if self.ave_score > 85 && self.appraisal_score > 80 {
                award += 4000;
            };
            if self.ave_score > 90 {
                award += 2000;
            };
            if self.ave_score > 85 && self.is_west {
                award += 1000;
            };
            if self.appraisal_score > 80 && self.is_cadre {
                award += 850;
            };
            award
        }
    }
    use std::vec::Vec;
    fn main() {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let student_count: usize = buf.trim().parse().unwrap();
        let mut students: Vec<Student> = Vec::with_capacity(student_count);
        for _ in 0..student_count {
            buf.clear();
            std::io::stdin().read_line(&mut buf).unwrap();
            let res: Vec<&str> = buf.trim().split(" ").collect(); 
            let name = res.get(0).unwrap();
            let ave_score: i32 = res.get(1).unwrap().parse().unwrap();
            let appraisal_score: i32 = res.get(2).unwrap().parse().unwrap();
            let is_cadre = match res.get(3).unwrap() {
                &"Y" => true,
                &"N" => false,
                _ => false,
            };
            let is_west = match res.get(4).unwrap() {
                &"Y" => true,
                &"N" => false,
                _ => false,
            };
            let paper_count: i32 = res.get(5).unwrap().parse().unwrap();
            students.push(Student {
                name: String::from(*name),
                ave_score:ave_score,
                appraisal_score:appraisal_score,
                is_cadre:is_cadre,
                is_west:is_west,
                paper_count:paper_count,
            })
        }
        let max_award_student = students.iter().max_by_key(|s| s.get_award()).unwrap();
        println!("{}", max_award_student.name);
        println!("{}", max_award_student.get_award());
        println!("{}", students.iter().fold(0, |acc,s| acc+s.get_award()));
    }
    
    
    
  • 0
    @ 6 年前

    #include<iostream>
    using namespace std;
    struct tstudent{
    string name,m,n;
    int f,c,num;
    };
    int N,sum,n1=0,n2=0,sum1;
    tstudent a[601];
    int jiang(int x){
    sum=0;
    if(a[x].f>80&&a[x].num>=1) sum+=8000;
    if(a[x].f>85&&a[x].c>80) sum+=4000;
    if(a[x].f>90) sum+=2000;
    if(a[x].f>85&&a[x].n=="Y") sum+=1000;
    if(a[x].c>80&&a[x].m=="Y") sum+=850;
    return sum;
    }
    int main(){
    cin>>N;
    for(int i=0;i<N;i++){
    cin>>a[i].name>>a[i].f>>a[i].c>>a[i].m>>a[i].n>>a[i].num;
    }
    for(int j=0;j<N;j++){
    if(jiang(j)>n2){
    n2=jiang(j);
    n1=j;
    }
    sum1+=jiang(j);
    }
    cout<<a[n1].name<<endl<<jiang(n1)<<endl<<sum1;
    return 0;

    }

  • 0
    @ 6 年前

    #include <iostream>
    #include <cstring>
    using namespace std;
    struct student
    {
    string name;
    int terminal; // 期末平均成绩
    int evaluation; // 班级评议成绩
    char cadres; // 是否学生干部
    char west; // 是否西部省份
    int papers; // 论文数
    int money=0; // 获取的奖学金
    } stu[100];
    int main()
    {
    int N, i, index, totalMoney;
    cin >> N;
    for (i=0; i<N; i++){
    cin >> stu[i].name >> stu[i].terminal >> stu[i].evaluation >> stu[i].cadres >> stu[i].west >> stu[i].papers;
    if (stu[i].terminal>80 && stu[i].papers>0) stu[i].money += 8000; // 院士奖学金
    if (stu[i].terminal>85 && stu[i].evaluation>80) stu[i].money += 4000; // 五四奖学金
    if (stu[i].terminal>90) stu[i].money += 2000; // 成绩优秀奖
    if (stu[i].terminal>85 && stu[i].west=='Y') stu[i].money += 1000; // 西部奖学金
    if (stu[i].evaluation>80 && stu[i].cadres=='Y') stu[i].money += 850; // 班级贡献奖

    }
    index = 0;
    totalMoney = stu[0].money;
    for (i=1; i<N; i++){
    if (stu[i].money > stu[index].money)
    index = i;
    totalMoney += stu[i].money;
    }
    cout << stu[index].name << endl;
    cout << stu[index].money << endl;
    cout << totalMoney << endl;
    return 0;
    }

  • 0

    不喜勿喷,谢谢。
    以下题解
    若有同雷者,纯属巧合

    
    #include <iostream>
    #include <string>
    using namespace std;
    struct Student
    {
        char name[20];                //姓名
        int score1;                   //期末成绩
        int score2;                   //班级成绩
        char leader;                  //是否是班干部
        char weststudent;             //是否是西部学生
        int article;                  //论文数
        int money;                    //个人总奖金
    };
    Student a[100];
    int main()
    {
     
        int max=0;                    //学生编号
        int sum=0;                    //总奖金
        int n;                        //学生总数
        cin>>n;                       //输入学生总数
        for(int i=0; i<n; i++)
        {
            cin>>a[i].name;
            cin>>a[i].score1;
            cin>>a[i].score2;
            cin>>a[i].leader;
            cin>>a[i].weststudent;
            cin>>a[i].article;
        }
        for(int j=0; j<n; j++)
        {
            a[j].money=0;
            if(a[j].score1>80&&a[j].article>=1)
                a[j].money+=8000;
            if(a[j].score1>85&&a[j].score2>80)
                a[j].money+=4000;
            if(a[j].score1>90)
                a[j].money+=2000;
            if(a[j].score1>85&&a[j].weststudent=='Y')
                a[j].money+=1000;
            if(a[j].score2>80&&a[j].leader=='Y')
                a[j].money+=850;
            sum+=a[j].money;
        }
        for(int k=0; k<n; k++)
        {
            if(a[k].money>a[max].money)
                max=k;
        }
        cout<<a[max].name<<endl;
        cout<<a[max].money<<endl;
        cout<<sum;
        return 0;
    }
    
    
    • 此题要认真(..•˘_˘•..)细心做(本蒟蒻认为)
      加油吧!!!
      祝(ˉ(∞)ˉ)
      蒟蒻们成为神犇...

    • @ 6 年前

      luogu的

  • 0
    @ 6 年前

    #include<iostream>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    struct node{
    string name;
    int qimo;
    int banji;
    char bangan;
    char xibu;
    int len;
    }a[101];
    int b[101]={0};
    int main(){
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
    cin>>a[i].name>>a[i].qimo>>a[i].banji>>a[i].bangan>>a[i].xibu>>a[i].len;
    }
    for(int i=0;i<n;i++){
    if(a[i].qimo>80&&a[i].len>=1)
    {
    b[i]+=8000;
    }
    if(a[i].qimo>85&&a[i].banji>80)
    {
    b[i]+=4000;
    }
    if(a[i].qimo>90)
    {
    b[i]+=2000;
    }
    if(a[i].qimo>85&&a[i].xibu=='Y')
    {
    b[i]+=1000;
    }
    if(a[i].banji>80&&a[i].bangan=='Y')
    {
    b[i]+=850;
    }
    }
    int max=b[0],maxi,sum=0;
    for(int i=1;i<n;i++)
    {
    if(max<b[i])
    {
    max=b[i];
    maxi=i;
    }
    }
    cout<<a[maxi].name<<endl<<b[maxi]<<endl;
    for(int i=0;i<n;i++)
    {
    sum+=b[i];
    }
    cout<<sum;
    return 0;
    }

  • 0
    @ 6 年前

    #include <stdio.h>
    struct stu
    {
    char a[20],d,e;
    int b,c,f,g;
    };
    int main()
    {
    int n,i=0,p=0,g=0;
    scanf ("%d",&n);
    struct stu s[n];
    for (;i<n;i++)
    {
    scanf("%s %d %d %c %c %d",&s[i].a,&s[i].b,&s[i].c,&s[i].d,&s[i].e,&s[i].f);
    s[i].g=0;
    if(s[i].b>80&&s[i].f)s[i].g+=8000;
    if(s[i].b>85&&s[i].c>80)s[i].g+=4000;
    if(s[i].b>90)s[i].g+=2000;
    if(s[i].b>85&&s[i].e=='Y')s[i].g+=1000;
    if(s[i].c>80&&s[i].d=='Y')s[i].g+=850;
    if(s[i].g>s[p].g)p=i;
    g+=s[i].g;
    }
    printf("%s\n%d\n%d",s[p].a,s[p].g,g);
    return 0;
    }

  • 0
    @ 6 年前
    #include <stdio.h>
    
    typedef struct
    {
        char name[20];    //姓名
        int final;    //期末成绩
        int asse;    //评定成绩
        char leader;
        char western;    //是否西部
        int paper;    //发表论文
        int salary;    //奖金
    }student;
    
    
    int salary(student p){    //计算奖金
        int average = p.final;
        int money = 0;
    
        if(average > 80 && p.paper >= 1)
            money = money + 8000;
        if(average > 85 && p.asse >80)
            money = money + 4000;
        if(average > 90)
            money = money + 2000;
        if(average > 85 && p.western =='Y')
            money = money + 1000;
        if(p.asse > 80 && p.leader == 'Y')
            money = money + 850;
        return money;
    }
    
    
    int main(int argc, char const *argv[])
    {   
        //录入学生信息
    
        int N;    //学生总数
        scanf("%d",&N);
        student temp;
        student a[N];
        for (int i = 0; i < N; i++)    //输入信息
        {
            scanf("%s %d %d %c %c %d ",&a[i].name,&a[i].final,&a[i].asse,&a[i].leader,&a[i].western,&a[i].paper);
            a[i].salary = salary(a[i]);
        }
        
        //求最多奖学金的学生
        for(int i = 1;i < N;i++){
            if(a[i].salary > a[0].salary){
                temp = a[i];
                a[i] = a[0];
                a[0] = temp;
            }
        }
        printf("%s\n%d\n",a[0].name,a[0].salary);
    
        //输出总奖学金
        int all = 0;
        for (int i = 0; i < N; i++)
        {
            all = all + a[i].salary;
        }
        printf("%d\n",all );
        return 0;
    }
    
  • 0
    @ 6 年前

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int main()
    {
    char s[100][20],c1,c2;
    int n,sum=0,max=0,score1,score2,num,a,b,k;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
    scanf("%s %d %d %c %c %d",&s[i],&score1,&score2,&c1,&c2,&num);
    a=c1=='Y'?1:0;
    b=c2=='Y'?1:0;
    int tmp=0;
    if((score1>80)&&(num>0))tmp+=8000;
    if((score1>85)&&(score2>80))tmp+=4000;
    if(score1>90)tmp+=2000;
    if(b&&(score1>85))tmp+=1000;
    if(a&&(score2>80))tmp+=850;
    sum+=tmp;
    if(tmp>max){max=tmp;k=i;}
    }
    printf("%s\n%d\n%d\n",s[k],max,sum);
    return 0;
    }

  • 0
    @ 6 年前

    刚从一个pas党转为c++党,第一次写的代码。。
    ```cpp
    #include<iostream>
    #include<cstdio>
    #include<string.h>
    #include<ctype.h>
    using namespace std;
    int main()
    {
    int n,qm,by,lw,len,i,zh,num,max,j,len1;
    char k,xb,xg,name[100],zd[100];

    scanf("%d\n",&n);
    k=' ';
    for (i=0; i<=90; i++)
    {
    name[i]=k;
    zd[i]=k;
    }
    max=0; zh=0; len=0; len1=0;
    for (i=1; i<=n; i++)
    {
    len=0;
    if (i<n)
    scanf("%s %d %d %c %c %d\n",&name,&qm,&by,&xg,&xb,&lw);
    else
    scanf("%s %d %d %c %c %d",&name,&qm,&by,&xg,&xb,&lw);
    for (j=0; j<=50; j++)
    if (isalpha(name[j])!=0)
    len++;
    else
    break;
    num=0;
    if (qm>80 && lw>0)
    num=num+8000;
    if (qm>85 && by>80)
    num=num+4000;
    if (qm>90)
    num=num+2000;
    if (qm>85 && xb=='Y')
    num=num+1000;
    if (by>80 && xg=='Y')
    num=num+850;
    if (num>max)
    {
    max=num;
    for (j=0; j<len; j++)
    zd[j]=name[j];
    len1=len;
    }
    zh=zh+num;
    }
    for (i=0; i<len1; i++)
    printf("%c",zd[i]);
    printf("\n");
    printf("%d\n",max);
    printf("%d\n",zh);
    return 0;
    }
    ```

  • 0
    @ 6 年前

    此题考查的是基础知识,NOIP的标准题解,OJ评测状态。
    这道题需要提醒的是:
    1)此题不能用sort()排序,sort是一个不稳定的排序算法,否则会有一个测试点不能AC(#9textdata)。改正方法很简单:
    if (max<a[i].sum)//判断最大值-奖学金最多
    {
    max=a[i].sum;//找到并赋值
    big=i;//将它的id标注,以备输出好用
    }
    2)结构体定义:
    struct 结构体名{
    成员
    }结构体数组;

    标程如下:
    #include <iostream>
    #include <string>
    using namespace std;
    struct student{
    string name;//姓名
    int s1;//期末平均得分
    int s2;//评议成绩
    char x;//是否是班干部
    char y;//是否是西部学生
    int t;//发表的议论次数
    int sum;//总奖学金
    }a[101];//定义结构体数组
    int main()
    {
    int n,total=0,max=-1,big;//total_n名同学奖学金总和 max_n名同学中的奖学金的那名同学 big_那名同学的编号
    cin>>n;
    for (int i=1;i<=n;i++)
    {
    cin>>a[i].name>>a[i].s1>>a[i].s2>>a[i].x>>a[i].y>>a[i].t; //输入
    if (a[i].s1>80 && a[i].t>=1) a[i].sum+=8000; //1
    if (a[i].s1>85 && a[i].s2>80) a[i].sum+=4000; //2
    if (a[i].s1>90) a[i].sum+=2000; //3
    if (a[i].s1>85 && a[i].y=='Y') a[i].sum+=1000; //4
    if (a[i].s2>80 && a[i].x=='Y') a[i].sum+=850; //5
    total+=a[i].sum;//求和
    if (max<a[i].sum)//判断最大值
    {
    max=a[i].sum;
    big=i;
    }
    }
    cout<<a[big].name<<endl<<a[big].sum<<endl<<total<<endl; //输出
    return 0;
    }

  • 0
    @ 6 年前

    GoLang
    ```go
    package main

    import (
    "fmt"
    )

    func main() {

    var n int
    fmt.Scanf("%d\n", &n)

    StudArr := [200]student{}

    for i := 0; i < n; i++ {
    var name string
    var qm, bj, paper int
    var IsGB, IsWest string

    fmt.Scanf("%s %d %d %s %s %d\n", &name, &qm, &bj, &IsGB, &IsWest, &paper)
    //fmt.Println(name, qm, IsGB, IsWest, paper)

    stud := student{name, qm, bj, paper, IsGB, IsWest, 0}
    stud.CalcMoney()

    StudArr[i] = stud
    }

    MaxMoney := 0
    winner := ""
    sum := 0

    for i := 0; i < n; i++ {

    thisMoney := StudArr[i].money
    sum += thisMoney

    if i == 0 || thisMoney > MaxMoney {
    MaxMoney = thisMoney
    winner = StudArr[i].name
    }
    }

    fmt.Printf("%s\n", winner)
    fmt.Printf("%d\n", MaxMoney)
    fmt.Printf("%d", sum)

    }

    type student struct {
    name string
    qm, bj, paper int
    IsGB, IsWest string
    money int
    }

    func (p *student) CalcMoney() {

    sum := 0

    if p.qm > 80 && p.paper >= 1 {
    sum += 8000
    }

    if p.qm > 85 && p.bj > 80 {
    sum += 4000
    }

    if p.qm > 90 {
    sum += 2000
    }

    if p.qm > 85 && p.IsWest == "Y" {
    sum += 1000
    }

    if p.bj > 80 && p.IsGB == "Y" {
    sum += 850
    }

    p.money = sum
    }

信息

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