C + + who took the most scholarships ACM

Source: Internet
Author: User

/************************************************************************/
/*filename: Scholarship Issues
/*author:pengluer
/*date:2009/07/20
/*comment:
Problem description
The practice of a school is to grant scholarships after each semester's final exams. Awarded a total of five scholarships, the conditions are different: 1 Fellows scholarship, 8000 yuan per person, the final average score is higher than 80 points (>80), and in this semester published 1 or 1 papers in the students are available; 2 scholarship, May Fourth yuan per person, The average grade is higher than 85 (>85), and students with class evaluation score above 80 points (>80) are eligible, 3 the Outstanding Achievement Award, 2000 yuan per person, the final average score is higher than 90 points (>90) of the students can be obtained; 4 Western scholarship, 1000 yuan per person, Students in the western provinces with an average grade of 85 (>85) were awarded a 5 class Contribution award, 850 yuan per person, and a student cadre with a class review score above 80 points (>80); Each student can also receive a number of scholarships at the same time. For example, Yiao Lin's final average score is 87 points, Class review score 82 points, and he is a student cadre, then he can get May Fourth Scholarship and Class contribution award, the total bonus is 4850 yuan. Now give a number of students data, please calculate which students receive the highest total number of bonuses (assuming that there are always students to meet the conditions for scholarship).

Input
The first line entered is an integer n (1 <= n <= 100), representing the total number of students. The next n rows per line is a student's data, from left to right is the name, the final average grade, class review results, whether the student cadres, whether the western provinces students, as well as the number of published papers. The name is a string consisting of uppercase and lowercase letters of no more than 20 (without spaces); The final average and class review scores are integers from 0 to 100 (including 0 and 100); whether the student cadre and the 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 two contiguous data items are separated by a single space.

Output
The output includes three lines, the first line is the name of the student who gets the most bonuses, and the second line is the total number of bonuses the student receives. If two or more than two students receive the most bonus, output the names of the first students in the input file that appear among them. The third line is the total number of scholarships awarded to these n students.

Sample Input
4
Yaolin Y N 0
Chenruiyi N Y 1
LiXin N N 0
Zhangqin Y N 1

Sample Output
Chenruiyi
9000
28700
/************************************************************************/
#include <iostream>
using namespace Std;
struct student
{
Char name[20];
int Qm;
int Py;
Char Sm;
Char Es;
int Fb;
};

int main ()
{
int n;
int a[100] = {0};
cin>>n;
if (n>100| | N&LT;1)
{
return 0;
}
Student *s = new Student[n];
for (int i = 0;i<n;i++)
{
Cin>>s[i]. Name>>s[i]. Qm>>s[i]. Py>>s[i]. Sm>>s[i]. Es>>s[i]. Fb;
}
for (int i = 0;i<n;i++)
{
if (s[i). QM&LT;=80)
{
if (s[i). PY&GT;80)
{
if (s[i). sm== ' Y ' | | S[i]. sm== ' Y ')
{
a[i]+=850;
}
}
}
if (s[i). QM&GT;80)
{
if (s[i). Fb>=1)
{
a[i]+=8000;
}
if (s[i). PY&GT;80)
{
if (s[i). sm== ' Y ' | | S[i]. sm== ' Y ')
{
a[i]+=850;
}
}
if (s[i). QM&GT;85)
{
if (s[i). es== ' Y ' | | S[i]. es== ' Y ')
{
a[i]+=1000;
}
if (s[i). PY&GT;80)
{
a[i]+=4000;
}
}
if (s[i). QM&GT;90)
{
a[i]+=2000;
}
}
}
int sum=0;
int maxmoney=a[0];
int j=0;
for (int i = 0;i<n;++i)
{
Sum+=a[i];
if (Maxmoney<a[i])
{
Maxmoney = A[i];
J=i;
}
}
COUT&LT;&LT;S[J]. Name<<endl
<<maxmoney<<endl
<<sum<<endl;
return 0;
}

//////////////////////////////////////////////////////////////////////

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.