P1051 谁拿了最多奖学金 洛谷 (C++)(简单模拟)

根据题意模拟就好了,更新最大值,记录下标。

(话说我也想要这么多的奖学金啊..

#include <iostream>
#include <cctype>
#include <cstdio>
#define ll long long

using namespace std ;

typedef struct{
    string name ;
    ll end_grade ;
    ll class_grade ;
    char is_Stuleader ;
    char is_western ;
    ll number ;
    ll money ;
}meassage ;

int main(){
    ll t ;
    cin >> t ;
    ll index = -1 ;
    ll maxx = -1 ;
    ll tot = 0 ;
    meassage meassage[105] ;
    for ( ll i = 0 ; i < t ; i ++ ){
        meassage[i].money = 0 ;
        cin >> meassage[i].name >> meassage[i].end_grade >> meassage[i].class_grade >> meassage[i].is_Stuleader >> meassage[i].is_western >> meassage[i].number ;
        if ( meassage[i].end_grade > 80 && meassage[i].number >= 1 ){
            meassage[i].money += 8000 ;
        }
        if ( meassage[i].end_grade > 85 && meassage[i].class_grade > 80 ){
            meassage[i].money += 4000 ;
        }
        if ( meassage[i].end_grade > 90 ){
            meassage[i].money += 2000 ;
        }
        if ( meassage[i].is_western == 'Y' && meassage[i].end_grade > 85 ){
            meassage[i].money += 1000 ;
        }
        if ( meassage[i].is_Stuleader == 'Y' && meassage[i].class_grade > 80 ){
            meassage[i].money += 850 ;
        }
        tot += meassage[i].money ;
        if ( maxx < meassage[i].money ){
            maxx = meassage[i].money ;
            index = i ;
        }
    }
    cout << meassage[index].name << endl << meassage[index].money << endl << tot ;
    return 0 ;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值