P1051 求大佬!!
查看原帖
P1051 求大佬!!
332645
linhe4034楼主2020/5/28 12:38

Markdown 全都WA: 可在DEV C++测试没错, 帮看看:

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
struct STUDENT{
	char name[21];
	int test_score;
	int class_score;
	char montior;
	char west;
	int text;
	int money;
};
int student_money(STUDENT check_person){
	int check_person_money=0;
	if((check_person.test_score>80)&&(check_person.text>0)){
		check_person_money+=8000;
	}
	if((check_person.test_score>85)&&(check_person.class_score>80)){
		check_person_money+=4000;
	}
	if(check_person.test_score>90){
		check_person_money+=2000;
	}
	if((check_person.test_score>85)&&(check_person.west=='Y')){
		check_person_money+=1000;
	}
	if((check_person.class_score>80)&&(check_person.montior=='Y')){
		check_person_money+=850;
	}
	return check_person_money;
}
int main(){
	struct STUDENT person[105];
	int student,max_money=-1;
	int max_person,all_money=0;
	cin>>student;
	for(int i=0;i<student;i++){
		cin>>person[i].name;
		cin>>person[i].test_score;
		cin>>person[i].class_score;
		cin>>person[i].montior;
		cin>>person[i].west;
		cin>>person[i].text;
		person[i].money=0;
	}
	for(int i=0;i<student;i++){
		person[i].money=student_money(person[i]);
	}
	for(int i=0;i<student;i++){
		all_money+=person[i].money;
		if(max_money<person[i].money){
			max_money=person[i].money;
			max_person=i;
		}
	}
	cout<<endl;
	cout<<person[max_person].name<<endl;
	cout<<max_money<<endl;
	cout<<all_money;
	return 0;
}
2020/5/28 12:38
加载中...