508 条题解

  • 0
    @ 2019-11-20 22:13:19

    这里用到了结构数组动态分配内存大家可以看看
    #include<iostream>
    #include<string>
    #include<malloc.h>
    #define LEN sizeof(struct Student)
    using namespace std;
    struct Student{
    char name[100];
    int gard_exam;
    int gard_evaluate;
    char student_leader[1];
    int nums_paper;
    char student_west[1];

    };

    int main(){
    int n;
    cin >> n;
    struct Student *stu=NULL;
    stu = (struct Student *)malloc(sizeof(struct Student)*n);
    for (int i = 0; i < n; i++){
    cin >> stu[i].name >> stu[i].gard_exam >> stu[i].gard_evaluate >> stu[i].student_leader >> stu[i].student_west >> stu[i].nums_paper;
    }
    int sum_grad=0;
    int max_grad = 0;
    string name_cout;
    for (int i = 0; i < n; i++){
    int t_grad = 0;
    if (stu[i].gard_exam > 80 && stu[i].nums_paper >= 1){
    t_grad += 8000;
    }
    if (stu[i].gard_exam > 85 && stu[i].gard_evaluate > 80){
    t_grad += 4000;
    }
    if (stu[i].gard_exam > 90){
    t_grad += 2000;
    }
    if (stu[i].gard_exam > 85 && stu[i].student_west[0]=='Y'){
    t_grad += 1000;
    }
    if (stu[i].gard_exam > 80 && stu[i].student_leader[0] == 'Y'){
    t_grad += 850;
    }
    sum_grad = sum_grad+t_grad;
    if (max_grad < t_grad){
    max_grad = t_grad;
    name_cout = stu[i].name;
    }
    }
    cout << name_cout << endl;
    cout << max_grad << endl;
    cout << sum_grad << endl;
    }

  • 0
    @ 2019-09-27 19:41:51

    暴力模拟,大H2O题目
    祝大家全AC

    
    #include<bits/stdc++.h>
    #define FOR(i,n,m) for(int i=n;i<=m;i++)
    using namespace std;
    struct student{
        string name;
        int endtest,classtest,stu,west,lw,money;
    }a[105];
    int n,allmoney,ans=0,now=0;
    int main()
    {
        char s,w;
        cin>>n;
        FOR(i,1,n)
        {
            cin>>a[i].name;
            cin>>a[i].endtest>>a[i].classtest;
            cin>>s>>w>>a[i].lw;
            if(s=='Y')
            a[i].stu=1;
            else
            a[i].stu=0;//是否是学生干部 
            
            if(w=='Y')
            a[i].west=1;
            else
            a[i].west=0;//是否是西部学生 
            
            //开始颁发奖学金 
            if(a[i].endtest>80&&a[i].lw>=1)
            a[i].money+=8000;//院士奖学金
            
            if(a[i].endtest>85&&a[i].classtest>80)
            a[i].money+=4000;//五四奖学金
            
            if(a[i].endtest>90)
            a[i].money+=2000;//成绩优秀奖
            
            if(a[i].endtest>85&&a[i].west==1)
            a[i].money+=1000;//西部奖学金
            
            if(a[i].classtest>80&&a[i].stu==1)
            a[i].money+=850;//班级贡献奖
            
            allmoney+=a[i].money;//计算发出奖学金总和    
            
            if(now<a[i].money)
            {
                now=a[i].money;
                ans=i;
            }//查找奖学金最高者 
        }
    
    
        cout<<a[ans].name<<'\n'<<a[ans].money<<'\n'<<allmoney;
        return 0;
    }
    
  • 0
    @ 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
    最后吐槽一句:这是什么学校?发这么多奖学金?

  • 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-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-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;
    }
    
    
  • 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-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;
    }
    
  • 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-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
      厉害了我的欧阳

  • 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-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;
    }

信息

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