C++求谁拿了最多奖学金

C++求谁拿了最多奖学金

//Author:PanDaoxi
#include <iostream>
using namespace std;
struct student{
	char name[21];
	int avg,review;
	char iswest,leader;
	int text,total;
}stu[101];
int main(){
	int n,sum=0,max=0,num=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>stu[i].name;
		cin>>stu[i].avg;
		cin>>stu[i].review;
		cin>>stu[i].leader;
		cin>>stu[i].iswest;
		cin>>stu[i].text;
	}
	for(int i=0;i<n;i++){
		if(stu[i].avg>80&&stu[i].text>=1) stu[i].total+=8000;
		if(stu[i].avg>85&&stu[i].review>80) stu[i].total+=4000;
		if(stu[i].avg>90) stu[i].total+=2000;
		if(stu[i].avg>85&&stu[i].iswest=='Y') stu[i].total+=1000;
		if(stu[i].avg>80&&stu[i].leader=='Y') stu[i].total+=850;
	}
	for(int i=0;i<n;i++){
		if(stu[i].total>max){
			max=stu[i].total;
			num=i;	
		}
	}
	cout<<stu[num].name<<endl;
	cout<<stu[num].total<<endl;
	for(int i=0;i<n;i++) sum+=stu[i].total;
	cout<<sum<<endl;
	return 0;
}

C++求谁拿了最多奖学金

上一篇:Django ORM聚合查询,分组查询


下一篇:0x06 给树染色