Preliminary questions
Description: After the assessment of the final exam for 10 students, instructor a needs to draw a pass. The requirements are as follows:
(1) the pass line is a multiple of 10;
(2) ensure that at least 60% of students pass the course;
(3) if all the students score higher than 60, the pass rate is 60.
(4) The higher the pass line, the better, but the maximum length cannot exceed 60
Input: enter 10 integers; values: 0 ~ 100
Output: the output pass, a multiple of 10.
Input example: 61 51 49 30 20 10 70 80 90 99
Output sample: 50
Solution: from high to low enumeration pass lines, the first pass line that meets the requirements is the answer.
# Include <iostream> # include <vector> using namespace STD; void main () {vector <int> VES (10, 0); For (INT I = 0; I <10; I ++) CIN> ves [I]; int res, num; // pass res, num passing person for (RES = 60; Res> = 0; res-= 10) {num = 0; For (INT I = 0; I <10; I ++) {If (VES [I]> = res) num ++;} If (Num >=6) {cout <res <Endl; break ;}}}