根据题意模拟就好了,更新最大值,记录下标。
(话说我也想要这么多的奖学金啊..
#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 ; }
原文:https://www.cnblogs.com/Cantredo/p/9735921.html