F001A. Students at the FIPS P81104


Statement
 

pdf   zip

thehtml

The Poble Sec School of Informatics stores the information of its students and the marks they have obtained in the subjects they have done in this struct:

string name; // Student’s name int idn; // Student’s IDN vector<Subject> subj; // Subject list of the student };

where |Subject| is:

string name; // Subject’s name double mark; // Between 0 and 10, -1 shows NP };

Using these definitions, implement the function

that searches and returns the mark that the student |idn| has obtained at the subject |name|. If the student does not exist, or if he has not done the subject, or his mark is NP, the function must return −1.

You also have to implement the function:

that calculates and returns the average mark of the subjects in the vector |subj|. To calculate the average mark, NP must be ignored. If all the marks are NP or the vector is empty, the mean mark is −1.

Using the previous functions, you must implement:

that counts and sets in the output parameter |counter| the number of students in the vector |stu| that have a average mark greater than the mark that student |idn| has obtained at the subject |name|.

Precondition

There are not repeated students. In the list of subjects of each student there are not repeated subjects.

Observation

The main program is already done; do not modify it. This program reads the student’s data, then prints the result of your |count()| function for each combination student-subject of the input.

(In the instance, the average marks of Helen, Michael, Peter, Alicia, Paul, John and George are respectively 9.5, 8, 0, 5.25, −1, 9.25 and −1. The 2 in the output corresponds to Helen and John. The 1 corresponds to Helen. The 5 correspond to Helen, Michael, Peter, Alicia and John).

Public test cases
  • Input

    7
    Helen_OConnell       12345678  4  P1 9   PHYSICS 9.5   IC 9.5   ALGEBRA 10
    Michael_Martin       77777777  3  ANALYSIS 8   P1 7   IC 9
    Peter_Great_Disaster 55599666  4  P1 0   PHYSICS -1   ALGEBRA 0   IC 0
    Alicia_Nottoo_Bad    55511111  4  XC 5   P1 6.5   PHYSICS 5.5   IL 4
    Paul_No_Registration 55544444  0
    John_Smith           55533333  2  P1 9.25   PHYSICS -1
    George_Calm          66666666  4  P1 -1   PHYSICS -1   IC -1   ALGEBRA -1
    
    12345678 P1
    55533333 P1
    55533333 PHYSICS
    55533333 PRAP
    11111111 P1
    

    Output

    2
    1
    5
    5
    5
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++