Selection of people born in given year
Posted on 2003-10-25
Hi can you advise me?
I should create a program which is called from the command line with one parameter. This parameter will be the number representing a year. The input is a list of records with 3 attributes just in this order:name, surname and birth-year. Output is a sorted list of persons born in year specified by command-line parameter.
- For the purposes of selection and sorting of the list create a function select_people and its definition place to the separated module (unit) born.C.
The funtion must have this prototype vector<string> select_people(multimap<string, int> &people, int year);
Parameter people is a reference on the indexed container (associated array), which associates "surname name" of type string with the birth-year (type int) for certain person.
Parameter year determines the year, according to which will be performed the selection of corresponding records from array people.
Function returns a vector (type string), which containes list of persons in alphabetical order (first surname)
- program will end after the input is read to the end (in Unix shortcut ctrl-D)
- Main module will read the individual records into associated array which will be then given to the function select_people. And then it will write output of this function.
for the insertion of records into the container multimap you can use the member function insert(pair<string, int>(string, int)).
thank you for your help