Solving
The topic itself has nothing to say.
But a universal group of questions let me understand the scanf () read the true meaning of the character. The most wonderful function of the scanf () function is to control the string in addition to the formatted string characters, if the match is successful . So we can "carefully design" this control string, in reading a single word Futillo to all spaces, enter and other interfering characters, no longer cin A (c) string and then manually judged.
Title 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).
Input Format:
The first line of the input file scholar.in 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 file Scholar.out 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.
input/Output sample
Input Sample # #:
4
Yaolin, 0, Y N
Chenruiyi N Y 1
LiXin N N 0
Zhangqin, Y N 1
Sample # # of output:
Chenruiyi
9000
28700
Code
#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>using namespace STD;intn, sum;structnode{BOOLCAD, WST;intNum, Ave, GRA, pro, Sch;Charnam[ -]; NodeBOOLCAD =false,BOOLWST =false,intnum =0,intAve =0,intGRA =0,intPro =0,intSch =0,Charxnam[ -] =""): CAD (CAD), WST (WST), num (num), Ave (AVE), GRA (GRA), Pro (Pro), Sch (Sch) { for(inti =0; I <=strlen(Xnam); ++i) Nam[i] = Xnam[i]; }BOOL operator< (Constnode& b)Const{if(Sch > B.sch)return true;if(Sch < B.sch)return false;returnNum < B.num; }}s[ the];intMain () {Charch[ -], CAD, WST;intAve, GRA, PRO, TMP;BOOLFC, FW;scanf("%d\n", &n); for(inti =0; I < n; ++i) {tmp =0;memset(CH,0,sizeof(CH)); FC = FW =false;scanf("%s%d%d%c%c%d\n", CH, &ave, &gra, &cad, &wst, &pro);//Zhuang i scanf Dafa if(CAD = =' Y ') FC =true;if(WST = =' Y ') FW =true;if(Ave > the&& Pro >0) tmp + =8000;if(Ave > -&& GRA > the) tmp + =4000;if(Ave > -) tmp + = -;if(Fw && Ave > -) tmp + = +;if(FC && GRA > the) tmp + =850; sum + = tmp; S[i] = node (FC, FW, I, Ave, GRA, PRO, TMP, CH); } sort (s, S + N);printf("%s\n%d\n%d\n", s[0].nam, s[0].sch, sum);return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Noip2005 who's got the most scholarship?