- 谁拿了最多奖学金
- 2016-11-06 20:57:01 @
// input code here
#include <iostream>
#include <string>
using namespace std;
struct student{
string name;
int a[3];
char b[2];
};
int main(){
int n;
cout<<"Enter the number of students: "<<endl;
cin>>n;
string a;
student* array=new student[n];
for (int i=0; i<n; i++) {
cin>>array[i].name>>array[i].a[0]>>array[i].a[1]>>array[i].b[0]>>array[i].b[1]>>array[i].a[2];
}
int index=0;
int max=0;
int total=0;
for (int i=0; i<n; i++) {
int money=0;
if ((array[i].a[0]>80)&&(array[i].a[2]>=1)) {
money+=8000;
}
if ((array[i].a[0]>85)&&(array[i].a[1]>80)) {
money+=4000;
}
if (array[i].a[0]>90) {
money+=2000;
}
if ((array[i].a[0]>85)&&(array[i].b[1]=='Y')) {
money+=1000;
}
if ((array[i].a[1]>80)&&(array[i].b[0]=='Y')) {
money+=850;
}
if (money>max) {
max=money;
index=i;
}
total+=money;
}
cout<<array[index].name<<endl;
cout<<max<<endl;
cout<<total<<endl;
}
1 条评论
-
cy_z LV 4 @ 2017-05-19 20:21:48
cout<<"Enter the number of students: "<<endl;
把这个去掉
- 1