首页 > 编程语言 > 详细

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

时间:2018-10-01 22:29:34      阅读:244      评论:0      收藏:0      [点我收藏+]

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

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

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

 

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

原文:https://www.cnblogs.com/Cantredo/p/9735921.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!