Description
The practice of a school is to grant scholarships after the final exams of each semester. There are five scholarships issued, and the conditions for obtaining them are different:
1) Academician scholarship, 8000 yuan per person, the end of the average score of more than 80 points (>80), and in this semester published 1 or more than 1 papers students can be obtained;
2) May Fourth Scholarship, 4000 yuan per person, the end of the average score is higher than 85 points (>85), and the class appraisal result is higher than 80 (>80) students can be obtained;
3) Outstanding Achievement Award, 2000 yuan per person, students who have a final average score above 90 (>90) can be obtained;
4) Western Scholarship, 1000 yuan per person, and students from western provinces with a final average score above 85 (>85);
5) Class Contribution award, 850 yuan per person, the class appraisal result is higher than 80 points (>80) student cadres can be obtained;
As long as the criteria are met, there is no limit to the number of winners for each scholarship, and a number of scholarships are available for each student. For example, Yiao Lin's end-of-term average is 87 points, Class review score 82 points, and he is a student cadre, then he can also receive May Fourth Scholarship and Class contribution award, the total bonus is 4850 yuan.
Now give the relevant data for several students, please calculate which students get the highest total bonus (assuming that the students can meet the conditions for the scholarship).
formatInput Format
The first line of input is an integer n (1 <= n <= 100) that represents the total number of students. The next n rows each row is a student's data, from left to right in turn is the name, the end of the average score, the class appraisal results, whether the student cadre, is the western Province students, as well as the number of papers published. The name is a string of not more than 20 of the length of the letter in the case of uppercase and lowercase letters (without spaces); The final average and class review scores are integers between 0 and 100 (including 0 and 100), whether student cadres and Western provinces students are represented by a single character, y means yes, n means not The number of papers published is 0 to 10 integers (including 0 and 10). Each of the two adjacent data items is separated by a space.
output Format
The output includes three lines, the first row is the name of the student who received the most bonus, and the second line is the total number of bonuses that the student received. If there are two or two students who receive the most bonuses, the first student's name appears in the input file. The third line is the total number of scholarships received by these n students.
Example 1Sample Input 1[ copy ]
4 Yaolin, 0, Y N Chenruiyi N Y 1 LiXin n N 0 Zhangqin, Y N 1
Sample Output 1[ copy ]
Chenruiyi 9000 28700
Limit
1s
Code 1 is as follows:
#include <iostream>using namespace Std;int main () { char name1[20],name2[20]; char Weststudent,leader; int score1,score2,article; int n,sum=0,money,max=0; cin>>n; while (n--) { cin>>name1>>score1>>score2>>leader>>weststudent>> article; money=0; if ((score1>80) && (article>0)) money+=8000; if ((score1>85) && (score2>80)) money+=4000; if (score1>90) money+=2000; if ((score1>85) && (weststudent== ' Y ')) money+=1000; if ((score2>80) && (leader== ' Y ')) money+=850; Sum+=money; if (Money>max) { Max=money; for (int i=0;i<20;i++) name2[i]=name1[i]; } } cout<<name2<<endl<<max<<endl<<sum; return 0;}
Code 2 is as follows:
#include <iostream> #include <string>using namespace std;struct student{Char name[20]; name int score1; Final result int score2; Class results char leader; Whether is class cadre char weststudent; Whether it is a western student int article; Paper number int money; Total personal Bonus}; Student A[100];int Main () {int max=0; Student number int sum=0; Total bonus int n; Total students cin>>n; Enter the total number of students for (int i=0; i<n; i++) {cin>>a[i].name; cin>>a[i].score1; cin>>a[i].score2; cin>>a[i].leader; cin>>a[i].weststudent; cin>>a[i].article; } for (int j=0; j<n; J + +) {a[j].money=0; if (a[j].score1>80&&a[j].article>=1) a[j].money+=8000; if (a[j].score1>85&&a[j].score2>80) a[j].money+=4000; if (a[j].score1>90) a[j].money+=2000; if (a[j].score1>85&&a[j].weststudent== ' Y ') a[j].money+=1000; if (a[j].score2>80&&a[j].leader== ' Y ') a[j].money+=850; Sum+=a[j].money; } for (int k=0; k<n; k++) {if (A[k].money>a[max].money) max=k; } cout<<a[max].name<<endl; cout<<a[max].money<<endl; cout<<sum; return 0;}
Operation Result:
Code 1 is just met this question when written, if in our school's OJ platform should have passed, but only two points on the Vijos, and later saw other people's tips to use the structure to do, perfect AC
Vijos-who's got the most scholarships?